mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-25 17:00:45 +08:00
[svn-r978] Purpose: Bug fixes
Problems: There were three separate bugs in the h5toh4 converter worked on. They were: 1) When a loop was detected, the H4 file was missing references to paths which were available in the H5 file. 2) When an H4 SDS or Vdata was created from a H5 dataset, the H4 object was referenced in the root group, instead of the correct Vgroup. 3) The FIRST path taken to an object for the h5toh4 conversion could not involve a SOFTLINK. Solutions: The bug fixes were: 1) All of the associated references to available paths which occur in the H5 file, now appear in the H4 file. 2) After an H4 SDS or Vdata is created from a H5 dataset, the H4 object is tag/ref'ed in the appropriate Vgroup. 3) The FIRST path taken to an H5 object for the H5toh4 conversion may involve a HARDLINK, a SOFTLINK, or neither. The same is true of any additional paths to the same object. Platform tested: Solaris2.5
This commit is contained in:
parent
7d9d6add9d
commit
caeb6c614f
@ -5,7 +5,7 @@
|
||||
typedef struct shared_obj_t{
|
||||
unsigned long objno[2];
|
||||
char objname[1024];
|
||||
int displayed;
|
||||
int objflag;
|
||||
} shared_obj_t;
|
||||
|
||||
typedef struct table_t{
|
||||
@ -26,6 +26,11 @@ extern int search_obj (table_t, unsigned long *);
|
||||
extern void add_obj (table_t *, unsigned long *, char *);
|
||||
extern void dump_tables(void);
|
||||
extern herr_t find_shared_objs(hid_t , char *, void *);
|
||||
extern herr_t H5findobj_once(hid_t , char *, void *);
|
||||
extern int get_table_idx(int, unsigned long *);
|
||||
extern int get_tableflag(int, int);
|
||||
extern int set_tableflag(int, int);
|
||||
extern char* get_objectname(int, int);
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: init_table
|
||||
@ -53,17 +58,17 @@ int i;
|
||||
|
||||
for (i = 0; i < group_table.size; i++) {
|
||||
group_table.objs[i].objno[0] = group_table.objs[i].objno[1] = 0;
|
||||
group_table.objs[i].displayed = 0;
|
||||
group_table.objs[i].objflag = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < dset_table.size; i++) {
|
||||
dset_table.objs[i].objno[0] = dset_table.objs[i].objno[1] = 0;
|
||||
dset_table.objs[i].displayed = 0;
|
||||
dset_table.objs[i].objflag = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < type_table.size; i++) {
|
||||
dset_table.objs[i].objno[0] = dset_table.objs[i].objno[1] = 0;
|
||||
dset_table.objs[i].displayed = 0;
|
||||
dset_table.objs[i].objflag = 0;
|
||||
}
|
||||
|
||||
prefix = (char *) HDmalloc(prefix_len * sizeof (char));
|
||||
@ -145,7 +150,7 @@ int i;
|
||||
table->objs = HDrealloc (table->objs, table->size*sizeof(shared_obj_t));
|
||||
for (i = table->nobjs; i < table->size; i++) {
|
||||
table->objs[i].objno[0] = table->objs[i].objno[1] = 0;
|
||||
table->objs[i].displayed = 0;
|
||||
table->objs[i].objflag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,21 +183,21 @@ int i;
|
||||
printf ("%lu %lu %s %d\n", group_table.objs[i].objno[0],
|
||||
group_table.objs[i].objno[1],
|
||||
group_table.objs[i].objname,
|
||||
group_table.objs[i].displayed);
|
||||
group_table.objs[i].objflag);
|
||||
|
||||
printf("\ndset_table: # of entries = %d\n", dset_table.nobjs);
|
||||
for ( i = 0; i < dset_table.nobjs; i++)
|
||||
printf ("%lu %lu %s %d\n", dset_table.objs[i].objno[0],
|
||||
dset_table.objs[i].objno[1],
|
||||
dset_table.objs[i].objname,
|
||||
dset_table.objs[i].displayed);
|
||||
dset_table.objs[i].objflag);
|
||||
|
||||
printf("\ntype_table: # of entries = %d\n", type_table.nobjs);
|
||||
for ( i = 0; i < type_table.nobjs; i++)
|
||||
printf ("%lu %lu %s %d\n", type_table.objs[i].objno[0],
|
||||
type_table.objs[i].objno[1],
|
||||
type_table.objs[i].objname,
|
||||
type_table.objs[i].displayed);
|
||||
type_table.objs[i].objflag);
|
||||
}
|
||||
|
||||
|
||||
@ -266,7 +271,7 @@ int i;
|
||||
H5Gget_objinfo(type, ".", TRUE, &statbuf);
|
||||
if (search_obj (type_table, statbuf.objno) < 0) {
|
||||
add_obj (&type_table, statbuf.objno, tmp) ;
|
||||
type_table.objs[type_table.nobjs-1].displayed = 0;
|
||||
type_table.objs[type_table.nobjs-1].objflag = 0;
|
||||
}
|
||||
}
|
||||
H5Tclose(type);
|
||||
@ -283,10 +288,10 @@ int i;
|
||||
i = search_obj (type_table, statbuf.objno);
|
||||
if (i < 0) {
|
||||
add_obj (&type_table, statbuf.objno, tmp) ;
|
||||
type_table.objs[type_table.nobjs-1].displayed = 1; /* named data type */
|
||||
type_table.objs[type_table.nobjs-1].objflag = 1; /* named data type */
|
||||
} else {
|
||||
strcpy (type_table.objs[i].objname, tmp);
|
||||
type_table.objs[i].displayed = 1; /* named data type */
|
||||
type_table.objs[i].objflag = 1; /* named data type */
|
||||
}
|
||||
status = SUCCEED;
|
||||
break;
|
||||
@ -300,3 +305,264 @@ int i;
|
||||
return status;
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5findobj_once
|
||||
*
|
||||
* Purpose: Find objects only once and store them in tables
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Paul Harten
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-----------------------------------------------------------------------*/
|
||||
herr_t
|
||||
H5findobj_once(hid_t group, char *name, void __unused__ *op_data)
|
||||
{
|
||||
hid_t obj, type;
|
||||
H5G_stat_t statbuf;
|
||||
char *tmp;
|
||||
int status=SUCCEED;
|
||||
int i;
|
||||
|
||||
H5Gget_objinfo(group, name, TRUE, &statbuf);
|
||||
|
||||
tmp = (char *) HDmalloc ((strlen(prefix)+strlen(name)+2) * sizeof(char));
|
||||
|
||||
strcpy(tmp, prefix);
|
||||
|
||||
switch (statbuf.type) {
|
||||
|
||||
case H5G_GROUP:
|
||||
if ((obj=H5Gopen (group, name))>=0) {
|
||||
|
||||
if (prefix_len < (int)(strlen(prefix) + strlen(name) + 2)) {
|
||||
prefix_len *= 2;
|
||||
prefix = HDrealloc (prefix, prefix_len * sizeof(char));
|
||||
}
|
||||
strcat(strcat(prefix,"/"), name);
|
||||
|
||||
if (search_obj (group_table, statbuf.objno) < 0) {
|
||||
add_obj (&group_table, statbuf.objno, prefix);
|
||||
status = H5Giterate (obj, ".", NULL, (H5G_operator_t)H5findobj_once, NULL);
|
||||
}
|
||||
|
||||
strcpy(prefix, tmp);
|
||||
H5Gclose (obj);
|
||||
|
||||
} else
|
||||
status = FAIL;
|
||||
|
||||
break;
|
||||
|
||||
case H5G_DATASET:
|
||||
|
||||
strcat(tmp,"/");
|
||||
strcat(tmp,name); /* absolute name of the data set */
|
||||
if (search_obj (dset_table, statbuf.objno) < 0)
|
||||
add_obj (&dset_table, statbuf.objno, tmp);
|
||||
|
||||
if ((obj=H5Dopen (group, name))>=0) {
|
||||
type = H5Dget_type (obj);
|
||||
if (H5Tcommitted(type) > 0 ) {
|
||||
H5Gget_objinfo(type, ".", TRUE, &statbuf);
|
||||
if (search_obj (type_table, statbuf.objno) < 0) {
|
||||
add_obj (&type_table, statbuf.objno, tmp) ;
|
||||
type_table.objs[type_table.nobjs-1].objflag = 0;
|
||||
}
|
||||
}
|
||||
H5Tclose(type);
|
||||
H5Dclose (obj);
|
||||
status = SUCCEED;
|
||||
} else
|
||||
status = FAIL;
|
||||
|
||||
break;
|
||||
|
||||
case H5G_TYPE:
|
||||
strcat(tmp,"/");
|
||||
strcat(tmp,name); /* absolute name of the type */
|
||||
i = search_obj (type_table, statbuf.objno);
|
||||
if (i < 0) {
|
||||
add_obj (&type_table, statbuf.objno, tmp) ;
|
||||
type_table.objs[type_table.nobjs-1].objflag = 1; /* named data type */
|
||||
} else {
|
||||
strcpy (type_table.objs[i].objname, tmp);
|
||||
type_table.objs[i].objflag = 1; /* named data type */
|
||||
}
|
||||
status = SUCCEED;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
HDfree (tmp);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: get_table_idx
|
||||
*
|
||||
* Purpose: Determine if objects are in a link loop
|
||||
*
|
||||
* Return: Success: table index of object detected to be in loop
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Paul Harten
|
||||
*
|
||||
*-----------------------------------------------------------------------*/
|
||||
int
|
||||
get_table_idx(int type, unsigned long *objno)
|
||||
{
|
||||
int idx;
|
||||
|
||||
switch (type) {
|
||||
|
||||
case H5G_GROUP:
|
||||
|
||||
idx = search_obj(group_table, objno);
|
||||
break;
|
||||
|
||||
case H5G_DATASET:
|
||||
|
||||
idx = search_obj(dset_table, objno);
|
||||
break;
|
||||
|
||||
case H5G_TYPE:
|
||||
|
||||
idx = search_obj(type_table, objno);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
idx = -1;
|
||||
|
||||
}
|
||||
|
||||
return idx;
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: Get table flag setting
|
||||
*
|
||||
* Purpose: Keep the structures and variables used private to
|
||||
* this file.
|
||||
*
|
||||
* Return: Success: Boolean setting of the i'th element of the
|
||||
* object table flag
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Paul Harten
|
||||
*
|
||||
*-----------------------------------------------------------------------*/
|
||||
int
|
||||
get_tableflag(int type, int idx)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
|
||||
case H5G_GROUP:
|
||||
|
||||
return group_table.objs[idx].objflag;
|
||||
|
||||
case H5G_DATASET:
|
||||
|
||||
return dset_table.objs[idx].objflag;
|
||||
|
||||
case H5G_TYPE:
|
||||
|
||||
return type_table.objs[idx].objflag;
|
||||
|
||||
default:
|
||||
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: Set table flag setting
|
||||
*
|
||||
* Purpose: Keep the structures and variables used private to
|
||||
* this file.
|
||||
*
|
||||
* Return: Success: Boolean setting of the i'th element of the
|
||||
* object table flag
|
||||
*
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Paul Harten
|
||||
*
|
||||
*-----------------------------------------------------------------------*/
|
||||
int
|
||||
set_tableflag(int type, int idx)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
|
||||
case H5G_GROUP:
|
||||
|
||||
group_table.objs[idx].objflag = TRUE;
|
||||
return SUCCEED;
|
||||
|
||||
case H5G_DATASET:
|
||||
|
||||
dset_table.objs[idx].objflag = TRUE;
|
||||
return SUCCEED;
|
||||
|
||||
case H5G_TYPE:
|
||||
|
||||
type_table.objs[idx].objflag = TRUE;
|
||||
return SUCCEED;
|
||||
|
||||
default:
|
||||
|
||||
return FAIL;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: Get name of i'th object in table
|
||||
*
|
||||
* Purpose:
|
||||
*
|
||||
* Return: Success: strdup() of object name character string
|
||||
*
|
||||
* Failure: NULL
|
||||
*
|
||||
* Programmer: Paul Harten
|
||||
*
|
||||
*-----------------------------------------------------------------------*/
|
||||
char *
|
||||
get_objectname(int type, int idx)
|
||||
{
|
||||
|
||||
switch (type) {
|
||||
|
||||
case H5G_GROUP:
|
||||
|
||||
return strdup(group_table.objs[idx].objname);
|
||||
|
||||
case H5G_DATASET:
|
||||
|
||||
return strdup(dset_table.objs[idx].objname);
|
||||
|
||||
case H5G_TYPE:
|
||||
|
||||
return strdup(type_table.objs[idx].objname);
|
||||
|
||||
default:
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
1031
tools/h5toh4.c
1031
tools/h5toh4.c
File diff suppressed because it is too large
Load Diff
@ -151,10 +151,6 @@ TEST()
|
||||
;;
|
||||
esac
|
||||
|
||||
# if [ $noclean -eq 0 ]
|
||||
# then
|
||||
# $RM $output
|
||||
# fi
|
||||
}
|
||||
|
||||
|
||||
@ -236,25 +232,27 @@ MESG 3 "$TestName"
|
||||
$RM ./testfiles/*.hdf ./testfiles/*.tmp
|
||||
TEST tgroup.h5
|
||||
TEST tdset.h5
|
||||
TEST tdset2.h5
|
||||
TEST tattr.h5
|
||||
TEST tslink.h5
|
||||
TEST thlink.h5
|
||||
TEST tcompound.h5
|
||||
TEST tcompound2.h5
|
||||
TEST tall.h5
|
||||
TEST tdset2.h5
|
||||
TEST tcompound2.h5
|
||||
TEST tmany.h5
|
||||
$RM ./testfiles/*.tmp
|
||||
TEST tgroup.h5 tgroup.hdf
|
||||
TEST tdset.h5 tdset.hdf
|
||||
TEST tdset2.h5 tdset2.hdf
|
||||
TEST tattr.h5 tattr.hdf
|
||||
TEST tslink.h5 tslink.hdf
|
||||
TEST thlink.h5 thlink.hdf
|
||||
TEST tcompound.h5 tcompound.hdf
|
||||
TEST tcompound2.h5 tcompound2.hdf
|
||||
TEST tall.h5 tall.hdf
|
||||
TEST tdset2.h5 tdset2.hdf
|
||||
TEST tcompound2.h5 tcompound2.hdf
|
||||
TEST tmany.h5 tmany.hdf
|
||||
$RM ./testfiles/*.hdf ./testfiles/*.tmp
|
||||
TEST -m tgroup.h5 tdset.h5 tdset2.h5 tattr.h5 tslink.h5 thlink.h5 tcompound.h5 tcompound2.h5 tall.h5
|
||||
TEST -m tgroup.h5 tdset.h5 tattr.h5 tslink.h5 thlink.h5 tcompound.h5 tall.h5
|
||||
TEST -m tdset2.h5 tcompound2.h5 tmany.h5
|
||||
$RM ./testfiles/*.hdf ./testfiles/*.tmp
|
||||
else
|
||||
MESG 3 "$TestName <<<SKIPPED>>>"
|
||||
|
Loading…
x
Reference in New Issue
Block a user