Exemple #1
0
/*-------------------------------------------------------------*/
static hid_t findDependentField(pNXVcontext self,
		hid_t inFieldID,char *dpData)
{
	char *pPtr;
	hid_t fieldID, groupID;
	char fname[512], newPath[1024], groupName[1024];

	/*
		get at enclosing group
  */
	memset(groupName,0,sizeof(groupName));
	H5Iget_name(inFieldID,groupName,sizeof(groupName));
	pPtr = strrchr(groupName,'/');
	*pPtr = '\0';
	pPtr = NULL;

	pPtr = strchr(dpData,'/');

	if(pPtr != NULL){
		if(pPtr == dpData){
			/* absolute path */
			if(H5LTpath_valid(self->fileID,dpData,1)){
				fieldID = H5Oopen(self->fileID,dpData,H5P_DEFAULT);
				return fieldID;
			} else {
				return -1;
			}
		} else {
			/* relative path further along the path */
			snprintf(newPath,sizeof(newPath), "%s/%s", groupName, dpData);
			if(H5LTpath_valid(self->fileID,newPath,1)){
				fieldID = H5Oopen(self->fileID,newPath,H5P_DEFAULT);
				return fieldID;
			} else {
				return -1;
			}
		}
	} else {
		/* path within the group */
		groupID = H5Oopen(self->fileID, groupName,H5P_DEFAULT);
		if(H5LTfind_dataset(groupID,dpData)){
			fieldID = H5Dopen(groupID,dpData,H5P_DEFAULT);
			H5Oclose(groupID);
			return fieldID;
		} else {
			H5Oclose(groupID);
			return -1;
		}
	}

	return -1;
}
Exemple #2
0
int_f
h5ltpath_valid_c(hid_t_f *loc_id, 
                  _fcd path, 
                  size_t_f *pathlen, 
                  int_f *check_object_valid_c)
{
    htri_t ret = -1;
    char *c_path = NULL;
    hbool_t check_object_valid;

    /*
     * convert FORTRAN name to C name
     */
    if( NULL == (c_path = (char *)HD5f2cstring(path, (size_t)*pathlen)))
      goto done;
    
    check_object_valid = FALSE;
    if(*check_object_valid_c == 1)
      check_object_valid = TRUE;

    /*
     * call H5LTpath_valid function.
     */
    ret = H5LTpath_valid( (hid_t)*loc_id, c_path, check_object_valid );

done:
    if(c_path != NULL)
      HDfree(c_path);

    return (int_f)ret;
}
Exemple #3
0
/*--------------------------------------------------------------*/
static void validateLink(pNXVcontext self, hid_t groupID,
		xmlChar *name, xmlChar *target)
{
	hid_t objID;
	herr_t att;
	char linkTarget[512], dataPath[512];
  char nxdlPath[512], curPath[512];

	/*
		set our path for correct error printing
	*/
	snprintf(nxdlPath,sizeof(nxdlPath),"%s/%s", self->nxdlPath,
		(char *)name);
	NXVsetLog(self,"nxdlPath",nxdlPath);
	H5Iget_name(groupID,curPath,sizeof(curPath));
	snprintf(dataPath,sizeof(dataPath),"%s/%s", curPath,
		(char *)name);
	NXVsetLog(self,"dataPath",dataPath);

	/*
		log what we are doing
	*/
	NXVsetLog(self,"sev","debug");
	NXVprintLog(self,"message","Validating link %s at %s",
		(char *)name, (char *)target);
	NXVlog(self);

	/*
		now we really validate
	*/
	if(H5LTpath_valid(groupID,(char *)name, 1)){
		/*
		  The positive test means that the link exists and is pointing to
			a valid HDF5 object. This is alread good.
		*/
		objID = H5Oopen(groupID,(char *)name,H5P_DEFAULT);
		assert(objID >= 0); /* we just tested for existence, didn't we? */
		memset(linkTarget,0,sizeof(linkTarget));
		att = H5NXget_attribute_string(groupID,(char *)name,"target",linkTarget);
		if(att < 0){
				NXVsetLog(self,"sev","error");
				H5Iget_name(objID,dataPath,sizeof(dataPath));
				NXVsetLog(self,"dataPath",dataPath);
				NXVsetLog(self,"message","Link is missing required attribute target");
				NXVlog(self);
				self->errCount++;
		} else {
			/*
				test that the target attribute really points to something
				real. It could be that the link was done right but the
				target attribute set sloppily.
			*/
			if(!H5LTpath_valid(self->fileID,linkTarget,1)){
				NXVsetLog(self,"sev","error");
				H5Iget_name(objID,dataPath,sizeof(dataPath));
				NXVsetLog(self,"dataPath",dataPath);
				NXVprintLog(self,"message","Link target %s is invalid",
					linkTarget);
				NXVlog(self);
				self->errCount++;
			} else {
				validateLinkTarget(self,target,linkTarget);
			}
		}
		H5Oclose(objID);
	} else {
		NXVsetLog(self,"sev","error");
		NXVprintLog(self,"message",
			"Required link %s missing or not pointing to an HDF5 object",
			(char *)name);
		NXVlog(self);
		self->errCount++;
	}
}
Exemple #4
0
/*--------------------------------------------------------------
 Finding groups is hideous:
 * They may be specified by name. This seems easy but is complicated
   by the fact that the group name can either be a name attribute or
	 an attribute field.  A design flaw of NXDL, IMHO.
 * They may be specified by type and I need to search by NX_class.
---------------------------------------------------------------*/
static hid_t findGroup(pNXVcontext self, hid_t parentGroup, xmlNodePtr groupNode)
{
	xmlChar *name = NULL, *nxClass = NULL, *nodePath = NULL;
	xmlNodePtr cur = NULL;
	findByClassData fbcd;
	hid_t gid, status;
	hsize_t idx = 0;

  name = xmlGetProp(groupNode,(xmlChar *)"name");
	if(name == NULL){
		cur = groupNode->xmlChildrenNode;
		while(cur != NULL){
			if(xmlStrcmp(cur->name,(xmlChar *)"attribute") == 0){
				name = xmlGetProp(cur,(xmlChar *)"name");
				if(name != NULL){
					break;
				}
			}
			cur = cur->next;
		}
	}
	if(name != NULL){
		if(H5LTpath_valid(parentGroup,(char *)name, 1)){
			status = H5Gopen(parentGroup,(char *)name,H5P_DEFAULT);
		} else {
			status =  -1;
		}
		xmlFree(name);
		return status;
	}

	/*
		no name to be found: search by type
	*/
	nxClass = xmlGetProp(groupNode,(xmlChar *)"type");
	if(nxClass == NULL){
		NXVsetLog(self,"sev","error");
		nodePath = xmlGetNodePath(cur);
		NXVsetLog(self,"nxdlPath", (char *)nodePath);
		NXVsetLog(self,"message","Malformed group entry, type missing");
		NXVlog(self);
		xmlFree(nodePath);
		self->errCount++;
		return -1;
	}

	fbcd.nxClass = (char *)nxClass;
	fbcd.name = NULL;
	H5Literate(parentGroup, H5_INDEX_NAME, H5_ITER_INC, &idx,
		FindByClassIterator, &fbcd);
	if(fbcd.name != NULL){
		gid = H5Gopen(parentGroup,fbcd.name,H5P_DEFAULT);
		free(fbcd.name);
		xmlFree(fbcd.nxClass);
		return gid;
	}
	xmlFree(fbcd.nxClass);


	return -1;
}