summaryrefslogtreecommitdiffstats
path: root/tools/h5findshd.c
diff options
context:
space:
mode:
authorPaul Harten <pharten@ncsa.uiuc.edu>1998-12-21 04:05:28 (GMT)
committerPaul Harten <pharten@ncsa.uiuc.edu>1998-12-21 04:05:28 (GMT)
commitcaeb6c614fef11ec93ddda06eef1c35d566699ae (patch)
treed1ec07818306697fac73e09bf19e88b6026e4b00 /tools/h5findshd.c
parent7d9d6add9d55fd056fc097dbcf91a2f2e6de71c9 (diff)
downloadhdf5-caeb6c614fef11ec93ddda06eef1c35d566699ae.zip
hdf5-caeb6c614fef11ec93ddda06eef1c35d566699ae.tar.gz
hdf5-caeb6c614fef11ec93ddda06eef1c35d566699ae.tar.bz2
[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
Diffstat (limited to 'tools/h5findshd.c')
-rw-r--r--tools/h5findshd.c288
1 files changed, 277 insertions, 11 deletions
diff --git a/tools/h5findshd.c b/tools/h5findshd.c
index a18e2ac..b5cd0f9 100644
--- a/tools/h5findshd.c
+++ b/tools/h5findshd.c
@@ -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;
+
+ }
+
+}