summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2004-06-28 14:29:20 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2004-06-28 14:29:20 (GMT)
commitba717ead8b4344b6b4a1836e31be55f219ced407 (patch)
tree9aad828ff705ea60eaaab8670689c468490d4564 /tools/lib
parent52d1e37e8f5861820b0545f40f5233cf73998f9e (diff)
downloadhdf5-ba717ead8b4344b6b4a1836e31be55f219ced407.zip
hdf5-ba717ead8b4344b6b4a1836e31be55f219ced407.tar.gz
hdf5-ba717ead8b4344b6b4a1836e31be55f219ced407.tar.bz2
[svn-r8749] Purpose:
dumper new features Description: 1) added options for not printing : datasets, groups, datatypes, links 2) added a section for the user block 3) in the traversal routine, added the printing of an arrow for soft links and t he word HARDLINK for hardlinks the print of the file contents is made during traversal , instead of at the e nd of it (this is helpful for very large files, where the wait time can be very long) 4) changed the description of the fill value properties 5) added a colon after the printing of the array indices Solution: Platforms tested: linux AIX solaris Misc. update:
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, 66 insertions, 32 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 9ac321b..ab90ebb 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 9c1db43..6c143eb 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -16,14 +16,13 @@
#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 );
@@ -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;
@@ -344,7 +346,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,33 +376,38 @@ 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
+ /* search table
group with more than one link to it */
if (statbuf.nlink > 1)
{
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" );
}
}
+
break;
/*-------------------------------------------------------------------------
@@ -418,26 +425,30 @@ 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
+ /* search table
dataset with more than one link to it */
if (statbuf.nlink > 1)
{
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 +470,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,15 +485,34 @@ 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:
break;
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 5f68da4..671e17c 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -90,7 +90,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);