summaryrefslogtreecommitdiffstats
path: root/tools/h5stat/h5stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5stat/h5stat.c')
-rw-r--r--tools/h5stat/h5stat.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index 4554c40..0176fd5 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -22,6 +22,9 @@
#include "h5trav.h"
#include "hdf5.h"
+/* Name of tool */
+#define PROGRAMNAME "h5stat"
+
/* Parameters to control statistics gathered */
#define SIZE_SMALL_GROUPS 10
#define SIZE_SMALL_ATTRS 10
@@ -97,8 +100,6 @@ typedef struct iter_t {
} iter_t;
-const char *progname = "h5stat";
-int d_status = EXIT_SUCCESS;
static int display_all = TRUE;
static int display_file = FALSE;
static int display_file_metadata = FALSE;
@@ -393,7 +394,7 @@ group_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
* Tuesday, August 16, 2005
*
* Modifications:
- * 2/2010; Vailin Choi
+ * 2/2010; Vailin Choi
* Handle external data (brought over from trunk h5stat)
*
*-------------------------------------------------------------------------
@@ -581,7 +582,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
* Failure: -1
*
* Programmer: Vailin Choi; July 7th, 2009
- *
+ *
* Modifications:
* 2/2010; Vailin Choi
* Gather attribute info for named datatype
@@ -724,11 +725,11 @@ parse_command_line(int argc, const char *argv[])
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
@@ -782,15 +783,15 @@ parse_command_line(int argc, const char *argv[])
break;
default:
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end switch */
} /* end while */
/* check for file name to be processed */
if (argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg(h5tools_getprogname(), "missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end if */
@@ -1097,18 +1098,18 @@ print_dataset_info(const iter_t *iter)
/*-------------------------------------------------------------------------
* Function: print_dataset_metadata
- *
- * Purpose: Prints file space information for datasets' metadata
- *
+ *
+ * Purpose: Prints file space information for datasets' metadata
+ *
* Return: Success: 0
- *
+ *
* Failure: Never fails
- *
+ *
* Programmer: Vailin Choi; October 2009
* Brought over from trunk h5stat.
*
*-------------------------------------------------------------------------
- */
+ */
static herr_t
print_dset_metadata(const iter_t *iter)
{
@@ -1241,7 +1242,7 @@ print_file_statistics(const iter_t *iter)
display_dset = TRUE;
display_dset_dtype_meta = TRUE;
display_attr = TRUE;
-
+
display_file_metadata = TRUE;
display_group_metadata = TRUE;
display_dset_metadata = TRUE;
@@ -1312,13 +1313,13 @@ print_statistics(const char *name, const iter_t *iter)
/*-------------------------------------------------------------------------
* Function: main
- *
+ *
* Modifications:
* 2/2010; Vailin Choi
* Get the size of user block
- *
+ *
*-------------------------------------------------------------------------
- */
+ */
int
main(int argc, const char *argv[])
{
@@ -1329,6 +1330,9 @@ main(int argc, const char *argv[])
struct handler_t *hand;
H5F_info_t finfo;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable error reporting */
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -1336,7 +1340,7 @@ main(int argc, const char *argv[])
h5tools_init();
hand = parse_command_line (argc, argv);
if(!hand) {
- error_msg(progname, "unable to parse command line arguments \n");
+ error_msg(h5tools_getprogname(), "unable to parse command line arguments \n");
leave(EXIT_FAILURE);
} /* end if */
@@ -1346,7 +1350,7 @@ main(int argc, const char *argv[])
fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
if(fid < 0) {
- error_msg(progname, "unable to open file \"%s\"\n", fname);
+ error_msg(h5tools_getprogname(), "unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
} /* end if */
@@ -1355,7 +1359,7 @@ main(int argc, const char *argv[])
/* Get storge info for SOHM's btree/list/heap and superblock extension */
if(H5Fget_info(fid, &finfo) < 0)
- warn_msg(progname, "Unable to retrieve SOHM info\n");
+ warn_msg(h5tools_getprogname(), "Unable to retrieve SOHM info\n");
else {
iter.super_ext_size = finfo.super_ext_size;
iter.SM_hdr_storage_size = finfo.sohm.hdr_size;
@@ -1364,10 +1368,10 @@ main(int argc, const char *argv[])
} /* end else */
if((fcpl = H5Fget_create_plist(fid)) < 0)
- warn_msg(progname, "Unable to retrieve file creation property\n");
+ warn_msg(h5tools_getprogname(), "Unable to retrieve file creation property\n");
if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0)
- warn_msg(progname, "Unable to retrieve userblock size\n");
+ warn_msg(h5tools_getprogname(), "Unable to retrieve userblock size\n");
/* Walk the objects or all file */
if(display_object) {
@@ -1376,7 +1380,7 @@ main(int argc, const char *argv[])
u = 0;
while(hand[u].obj) {
if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0)
- warn_msg(progname, "Unable to traverse object \"%s\"\n", hand[u].obj);
+ warn_msg(h5tools_getprogname(), "Unable to traverse object \"%s\"\n", hand[u].obj);
else
print_statistics(hand[u].obj, &iter);
u++;
@@ -1384,7 +1388,7 @@ main(int argc, const char *argv[])
} /* end if */
else {
if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0)
- warn_msg(progname, "Unable to traverse objects/links in file \"%s\"\n", fname);
+ warn_msg(h5tools_getprogname(), "Unable to traverse objects/links in file \"%s\"\n", fname);
else
print_statistics("/", &iter);
} /* end else */
@@ -1392,7 +1396,7 @@ main(int argc, const char *argv[])
if (hand) free(hand);
if(H5Fclose(fid) < 0) {
- error_msg(progname, "unable to close file \"%s\"\n", fname);
+ error_msg(h5tools_getprogname(), "unable to close file \"%s\"\n", fname);
leave(EXIT_FAILURE);
}