summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c8
-rw-r--r--tools/lib/h5trav.c88
-rw-r--r--tools/lib/h5trav.h2
3 files changed, 65 insertions, 33 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index e9160ee..5ddf455 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -72,8 +72,8 @@ int h5diff(const char *fname1,
*-------------------------------------------------------------------------
*/
- nobjects1 = h5trav_getinfo( file1_id, NULL );
- nobjects2 = h5trav_getinfo( file2_id, NULL );
+ nobjects1 = h5trav_getinfo( file1_id, NULL, 0 );
+ nobjects2 = h5trav_getinfo( file2_id, NULL, 0 );
/*-------------------------------------------------------------------------
* get the list of objects in the files
@@ -88,8 +88,8 @@ int h5diff(const char *fname1,
goto out;
}
- h5trav_getinfo( file1_id, info1 );
- h5trav_getinfo( file2_id, info2 );
+ h5trav_getinfo( file1_id, info1, 0 );
+ h5trav_getinfo( file2_id, info2, 0 );
/*-------------------------------------------------------------------------
* object name was supplied
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index 08c75e6..0a4fb6e 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -16,17 +16,16 @@
#include "h5trav.h"
#include "H5private.h"
-
-
/* functions for traversal */
int traverse( hid_t loc_id,
const char *group_name,
trav_table_t *table,
trav_info_t *info,
- int *idx );
+ int *idx,
+ int print);
herr_t get_nnames( hid_t loc_id,
- const char *group_name );
+ const char *group_name );
herr_t get_name_type( hid_t loc_id,
const char *group_name,
@@ -49,7 +48,9 @@ herr_t get_name_type( hid_t loc_id,
*-------------------------------------------------------------------------
*/
-int h5trav_getinfo( hid_t file_id, trav_info_t *info )
+int h5trav_getinfo(hid_t file_id,
+ trav_info_t *info,
+ int print )
{
trav_table_t *table=NULL;
@@ -59,7 +60,7 @@ int h5trav_getinfo( hid_t file_id, trav_info_t *info )
trav_table_init( &table );
/* iterate starting on the root group */
- if (( nnames = traverse( file_id, "/", table, info, &nnames )) < 0 )
+ if (( nnames = traverse( file_id, "/", table, info, &nnames, print )) < 0 )
return -1;
/* free table */
@@ -89,7 +90,7 @@ int h5trav_gettable(hid_t fid, trav_table_t *travt)
int nnames=0;
/* iterate starting on the root group */
- if (( nnames = traverse(fid,"/",travt,NULL,&nnames))<0)
+ if (( nnames = traverse(fid,"/",travt,NULL,&nnames,0))<0)
return -1;
return 0;
@@ -309,7 +310,8 @@ int traverse( hid_t loc_id,
const char *group_name,
trav_table_t *table,
trav_info_t *info,
- int *idx )
+ int *idx,
+ int print)
{
char *name=NULL;
@@ -320,14 +322,12 @@ int traverse( hid_t loc_id,
int inserted_objs=0;
int i, j;
-
/* get the number of names */
if (( n_names = get_nnames( loc_id, group_name )) < 0 )
return -1;
for ( i = 0; i < n_names; i++)
{
-
if (get_name_type( loc_id, group_name, i, &name, &type ) < 0 )
return -1;
@@ -344,7 +344,7 @@ int traverse( hid_t loc_id,
H5E_BEGIN_TRY {
/* get info */
- H5Gget_objinfo( loc_id, path, 1, &statbuf);
+ H5Gget_objinfo( loc_id, path, FALSE, &statbuf);
} H5E_END_TRY;
/* add to array */
@@ -374,9 +374,13 @@ int traverse( hid_t loc_id,
{
/* add object to table */
trav_table_add(statbuf.objno, path, H5G_GROUP, table );
+
+ /* print it */
+ if (print)
+ printf(" %-10s %s\n", "group", path );
/* recurse with the absolute name */
- inserted_objs += traverse( loc_id, path, table, info, idx );
+ inserted_objs += traverse( loc_id, path, table, info, idx, print );
}
/* search table
@@ -386,17 +390,17 @@ int traverse( hid_t loc_id,
if ((j = trav_table_search(statbuf.objno, table )) < 0 )
return -1;
+ trav_table_addlink(table,j,path);
+
if ( table->objs[j].displayed == 0 )
{
table->objs[j].displayed = 1;
- trav_table_addlink(table,j,path);
}
else
{
-#if defined (H5_TRAV_DEBUG)
- printf("<%s> HARDLINK\n", path);
-#endif
- trav_table_addlink(table,j,path);
+ /* print it */
+ if (print)
+ printf(" %-10s %s %s\n", "group", path, "HARDLINK" );
}
}
@@ -418,6 +422,11 @@ int traverse( hid_t loc_id,
{
/* add object to table */
trav_table_add(statbuf.objno, path, H5G_DATASET, table );
+
+ /* print it */
+ if (print)
+ printf(" %-10s %s\n", "dataset", path );
+
}
/* search table
@@ -427,17 +436,17 @@ int traverse( hid_t loc_id,
if ((j = trav_table_search(statbuf.objno, table )) < 0 )
return -1;
+ trav_table_addlink(table,j,path);
+
if ( table->objs[j].displayed == 0 )
{
table->objs[j].displayed = 1;
- trav_table_addlink(table,j,path);
}
else
{
-#if defined (H5_TRAV_DEBUG)
- printf("<%s> HARDLINK\n", path);
-#endif
- trav_table_addlink(table,j,path);
+ /* print it */
+ if (print)
+ printf(" %-10s %s %s\n", "dataset", path, "(HARDLINK)" );
} /* displayed==1 */
} /* nlink>1 */
@@ -459,6 +468,10 @@ int traverse( hid_t loc_id,
{
/* add object to table */
trav_table_add(statbuf.objno, path, H5G_TYPE, table );
+
+ /* print it */
+ if (print)
+ printf(" %-10s %s\n", "datatype", path );
}
break;
@@ -470,17 +483,36 @@ int traverse( hid_t loc_id,
*/
case H5G_LINK:
+ {
+ char *targbuf=NULL;
+
+ /* increment */
+ inserted_objs++;
+
+ /* add object to table */
+ trav_table_add(statbuf.objno, path, H5G_LINK, table );
- /* increment */
- inserted_objs++;
-
- /* add object to table */
- trav_table_add(statbuf.objno, path, H5G_LINK, table );
-
+ if (statbuf.linklen>0)
+ {
+ targbuf=malloc(statbuf.linklen);
+ H5Gget_linkval(loc_id,path,statbuf.linklen,targbuf);
+ if (print)
+ printf(" %-10s %s -> %s\n", "link", path, targbuf);
+ if (targbuf)
+ free(targbuf);
+ }
+ else
+ {
+ if (print)
+ printf(" %-10s %s ->\n", "link", path);
+ }
+ }
+
break;
default:
+ printf(" %-10s %s\n", "User defined object", path );
break;
}
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 4493b0b..4d7f0cf 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -97,7 +97,7 @@ extern "C" {
* "h5trav info" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_getinfo( hid_t file_id, trav_info_t *info );
+int h5trav_getinfo( hid_t fid, trav_info_t *info, int print );
int h5trav_getindex( const char *obj, int nobjs, trav_info_t *info );
void h5trav_freeinfo( trav_info_t *info, int nobjs );
void h5trav_printinfo(int nobjs, trav_info_t *info);