summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perform/sio_perf.h1
-rw-r--r--tools/h5copy/h5copy.c30
-rw-r--r--tools/h5copy/h5copygentest.c6
-rw-r--r--tools/h5diff/h5diff_common.c8
-rw-r--r--tools/h5diff/h5diff_main.c8
-rw-r--r--tools/h5diff/h5diffgentest.c6
-rw-r--r--tools/h5diff/ph5diff_main.c9
-rw-r--r--tools/h5dump/h5dump.c326
-rw-r--r--tools/h5dump/h5dumpgentest.c3
-rwxr-xr-xtools/h5import/h5import.c6
-rw-r--r--tools/h5jam/getub.c26
-rw-r--r--tools/h5jam/h5jam.c48
-rw-r--r--tools/h5jam/h5unjam.c46
-rw-r--r--tools/h5jam/tellub.c26
-rw-r--r--tools/h5ls/h5ls.c15
-rw-r--r--tools/h5repack/h5repack.c30
-rw-r--r--tools/h5repack/h5repack_copy.c59
-rw-r--r--tools/h5repack/h5repack_filters.c1
-rw-r--r--tools/h5repack/h5repack_main.c41
-rw-r--r--tools/h5repack/h5repack_opttable.c12
-rw-r--r--tools/h5repack/h5repack_parse.c52
-rw-r--r--tools/h5repack/h5repack_verify.c26
-rw-r--r--tools/h5repack/h5repacktst.c5
-rw-r--r--tools/h5repack/testh5repack_detect_szip.c7
-rw-r--r--tools/h5stat/h5stat.c42
-rw-r--r--tools/lib/h5diff.h6
-rw-r--r--tools/lib/h5tools.c30
-rw-r--r--tools/lib/h5tools.h43
-rw-r--r--tools/lib/h5tools_error.h6
-rw-r--r--tools/lib/h5tools_ref.c7
-rw-r--r--tools/lib/h5tools_ref.h14
-rw-r--r--tools/lib/h5tools_utils.c8
-rw-r--r--tools/lib/h5tools_utils.h39
-rw-r--r--tools/lib/h5trav.h22
-rw-r--r--tools/misc/h5mkgrp.c39
35 files changed, 572 insertions, 481 deletions
diff --git a/perform/sio_perf.h b/perform/sio_perf.h
index bd05cfe..2417b6f 100644
--- a/perform/sio_perf.h
+++ b/perform/sio_perf.h
@@ -18,6 +18,7 @@
#include "sio_timer.h"
#ifndef STANDALONE
#include "H5private.h"
+#include "h5test.h"
#include "h5tools_utils.h"
#else
#include "sio_standalone.h"
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 0ea8e16..89cb5fb 100644
--- a/tools/h5copy/h5copy.c
+++ b/tools/h5copy/h5copy.c
@@ -19,8 +19,8 @@
#include <string.h>
#include <stdlib.h>
-const char *progname="h5copy";
-int d_status;
+/* Name of tool */
+#define PROGRAMNAME "h5copy"
/* command-line options: short and long-named parameters */
static const char *s_opts = "d:f:hi:o:ps:vV";
@@ -176,7 +176,7 @@ static int parse_flag(const char* str_flag, unsigned *flag)
}
else
{
- error_msg(progname, "Error in input flag\n");
+ error_msg("Error in input flag\n");
return -1;
}
@@ -216,7 +216,9 @@ main (int argc, const char *argv[])
int li_ret;
h5tool_link_info_t linkinfo;
- /* initialize h5tools lib */
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+/* initialize h5tools lib */
h5tools_init();
/* Check for no command line parameters */
@@ -266,7 +268,7 @@ main (int argc, const char *argv[])
break;
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
@@ -286,28 +288,28 @@ main (int argc, const char *argv[])
if (fname_src==NULL)
{
- error_msg(progname, "Input file name missing\n");
+ error_msg("Input file name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (fname_dst==NULL)
{
- error_msg(progname, "Output file name missing\n");
+ error_msg("Output file name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (oname_src==NULL)
{
- error_msg(progname, "Source object name missing\n");
+ error_msg("Source object name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (oname_dst==NULL)
{
- error_msg(progname, "Destination object name missing\n");
+ error_msg("Destination object name missing\n");
usage();
leave(EXIT_FAILURE);
}
@@ -324,7 +326,7 @@ main (int argc, const char *argv[])
*-------------------------------------------------------------------------*/
if (fid_src==-1)
{
- error_msg(progname, "Could not open input file <%s>...Exiting\n", fname_src);
+ error_msg("Could not open input file <%s>...Exiting\n", fname_src);
if (fname_src)
free(fname_src);
leave(EXIT_FAILURE);
@@ -347,7 +349,7 @@ main (int argc, const char *argv[])
*-------------------------------------------------------------------------*/
if (fid_dst==-1)
{
- error_msg(progname, "Could not open output file <%s>...Exiting\n", fname_dst);
+ error_msg("Could not open output file <%s>...Exiting\n", fname_dst);
if (fname_src)
free(fname_src);
if (fname_dst)
@@ -388,7 +390,7 @@ main (int argc, const char *argv[])
/* Create link creation property list */
if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
- error_msg(progname, "Could not create link creation property list\n");
+ error_msg("Could not create link creation property list\n");
goto error;
} /* end if */
@@ -396,13 +398,13 @@ main (int argc, const char *argv[])
if(parents) {
/* Set the intermediate group creation property */
if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) {
- error_msg(progname, "Could not set property for creating parent groups\n");
+ error_msg("Could not set property for creating parent groups\n");
goto error;
} /* end if */
/* Display some output if requested */
if(verbose)
- printf("%s: Creating parent groups\n", progname);
+ printf("%s: Creating parent groups\n", h5tools_getprogname());
} /* end if */
/*-------------------------------------------------------------------------
diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c
index b6346de..a79789a 100644
--- a/tools/h5copy/h5copygentest.c
+++ b/tools/h5copy/h5copygentest.c
@@ -21,6 +21,9 @@
#include "H5private.h"
#include "h5tools.h"
+/* Name of tool */
+#define PROGRAMNAME "h5copygentest"
+
/* HDF file names */
#define HDF_FILE1 "h5copytst.h5"
#define HDF_FILE2 "h5copy_ref.h5"
@@ -888,6 +891,9 @@ out:
int main(void)
{
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
Test_Obj_Copy();
Test_Ref_Copy();
Test_Extlink_Copy();
diff --git a/tools/h5diff/h5diff_common.c b/tools/h5diff/h5diff_common.c
index 75e1774..cf54a35 100644
--- a/tools/h5diff/h5diff_common.c
+++ b/tools/h5diff/h5diff_common.c
@@ -23,10 +23,6 @@ static int check_n_input( const char* );
static int check_p_input( const char* );
static int check_d_input( const char* );
-
-/* module-scoped variables */
-const char *progname = "h5diff";
-
/*
* Command-line options: The user can specify short or long-named
* parameters.
@@ -90,7 +86,7 @@ void parse_command_line(int argc,
usage();
h5diff_exit(EXIT_SUCCESS);
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
h5diff_exit(EXIT_SUCCESS);
case 'v':
options->m_verbose = 1;
@@ -174,7 +170,7 @@ void parse_command_line(int argc,
/* check for file names to be processed */
if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL)
{
- error_msg(progname, "missing file names\n");
+ error_msg("missing file names\n");
usage();
h5diff_exit(EXIT_FAILURE);
}
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c
index 8089161..297eb48 100644
--- a/tools/h5diff/h5diff_main.c
+++ b/tools/h5diff/h5diff_main.c
@@ -20,6 +20,9 @@
#include "h5diff_common.h"
#include "h5tools_utils.h"
+/* Name of tool */
+#define PROGRAMNAME "h5diff"
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -68,9 +71,6 @@
*/
-/* module-scoped variables */
-int d_status = EXIT_SUCCESS;
-
int main(int argc, const char *argv[])
{
int ret;
@@ -81,6 +81,8 @@ int main(int argc, const char *argv[])
hsize_t nfound=0;
diff_opt_t options;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
/*-------------------------------------------------------------------------
* process the command-line
*-------------------------------------------------------------------------
diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c
index 57abc04..26adbf4 100644
--- a/tools/h5diff/h5diffgentest.c
+++ b/tools/h5diff/h5diffgentest.c
@@ -20,6 +20,9 @@
#include "h5tools.h"
+/* Name of tool */
+#define PROGRAMNAME "h5diffgentest"
+
/*-------------------------------------------------------------------------
* Program: h5diffgentest
*
@@ -114,9 +117,6 @@ static int write_dset(hid_t loc_id,int rank,hsize_t *dims,const char *name,hid_t
*-------------------------------------------------------------------------
*/
-/* module-scoped variables */
-int d_status = EXIT_SUCCESS;
-
int main(void)
{
test_basic(FILE1, FILE2, FILE11);
diff --git a/tools/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c
index 1990138..7a43c73 100644
--- a/tools/h5diff/ph5diff_main.c
+++ b/tools/h5diff/ph5diff_main.c
@@ -20,6 +20,9 @@
#include <assert.h>
#include "h5diff_common.h"
+/* Name of tool */
+#define PROGRAMNAME "h5diff"
+
static void ph5diff_worker(int );
/*-------------------------------------------------------------------------
@@ -52,9 +55,6 @@ static void ph5diff_worker(int );
*-------------------------------------------------------------------------
*/
-/* module-scoped variables */
-int d_status = EXIT_SUCCESS;
-
int main(int argc, const char *argv[])
{
int nID = 0;
@@ -64,6 +64,9 @@ int main(int argc, const char *argv[])
const char *objname2 = NULL;
diff_opt_t options;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
outBuffOffset = 0;
g_Parallel = 1;
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 3156ba6..e4c5231 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -22,9 +22,8 @@
#include "h5tools_ref.h"
#include "h5trav.h"
-
-/* module-scoped variables */
-const char *progname = "h5dump";
+/* Name of tool */
+#define PROGRAMNAME "h5dump"
/* Macros for displaying objects */
#define begin_obj(obj,name,begin) \
@@ -68,7 +67,6 @@ typedef struct h5dump_table_list_t {
} *tables;
} h5dump_table_list_t;
-int d_status = EXIT_SUCCESS;
static int unamedtype = 0; /* shared datatype with no name */
static h5dump_table_list_t table_list = {0, 0, NULL};
static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
@@ -819,7 +817,7 @@ table_list_free(void)
for(u = 0; u < table_list.nused; u++) {
/* Release object id */
if(H5Idec_ref(table_list.tables[u].oid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
/* Free each table */
free_table(table_list.tables[u].group_table);
@@ -881,8 +879,8 @@ print_datatype(hid_t type,unsigned in_group)
else
printf("\"%s\"", obj->objname);
} else {
- error_msg(progname, "unknown committed type.\n");
- d_status = EXIT_FAILURE;
+ error_msg("unknown committed type.\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
switch(H5Tget_class(type)) {
@@ -1121,7 +1119,7 @@ print_datatype(hid_t type,unsigned in_group)
/* Type doesn't match any of above. */
printf("unknown_one_character_type;\n ");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
done:
H5Tclose(str_type);
@@ -1151,7 +1149,7 @@ print_datatype(hid_t type,unsigned in_group)
printf("H5T_STD_B64LE");
} else {
printf("undefined bitfield");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
break;
@@ -1258,7 +1256,7 @@ print_datatype(hid_t type,unsigned in_group)
default:
printf("unknown datatype");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
break;
}
} /* end else */
@@ -1401,11 +1399,11 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, vo
if((attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT)) < 0) {
indentation(indent + COL);
- error_msg(progname, "unable to open attribute \"%s\"\n", attr_name);
+ error_msg("unable to open attribute \"%s\"\n", attr_name);
indentation(indent);
end_obj(dump_header_format->attributeend,
dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
hid_t type, space;
@@ -1477,9 +1475,9 @@ dump_selected_attr(hid_t loc_id, const char *name)
/* Open the object with the attribute */
if((oid = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) {
indentation(COL);
- error_msg(progname, "unable to open object \"%s\"\n", obj_name);
+ error_msg("unable to open object \"%s\"\n", obj_name);
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return FAIL;
} /* end if */
@@ -1504,14 +1502,14 @@ dump_selected_attr(hid_t loc_id, const char *name)
dump_header_format->attributeblockend);
} else {
indentation(COL);
- error_msg(progname, "unable to open attribute \"%s\"\n", obj_name);
+ error_msg("unable to open attribute \"%s\"\n", obj_name);
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
/* Close object */
if(H5Oclose(oid) < 0) {
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return FAIL;
} /* end if */
@@ -1559,8 +1557,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
/* Stat the object */
if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get object information for \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to get object information for \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
goto done;
} /* end if */
@@ -1570,8 +1568,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
case H5O_TYPE_GROUP:
if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0)
{
- error_msg(progname, "unable to dump group \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to dump group \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else
@@ -1609,13 +1607,13 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
begin_obj(dump_header_format->datasetbegin, name,
dump_header_format->datasetblockbegin);
indentation(indent + COL);
- error_msg(progname,
+ error_msg(h5tools_getprogname(),
"internal error (file %s:line %d)\n",
__FILE__, __LINE__);
indentation(indent);
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
H5Dclose(obj);
goto done;
@@ -1678,16 +1676,16 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
dump_function_table->dump_dataset_function(obj, name, NULL);
H5Dclose(obj);
} else {
- error_msg(progname, "unable to dump dataset \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to dump dataset \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
break;
case H5O_TYPE_NAMED_DATATYPE:
if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg(progname, "unable to dump datatype \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
dump_function_table->dump_named_datatype_function(obj, name);
@@ -1696,8 +1694,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
break;
default:
- error_msg(progname, "unknown object \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unknown object \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
} /* end if */
@@ -1717,8 +1715,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
}
if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get link value\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to get link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
/* print the value of a soft link */
@@ -1808,8 +1806,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin);
if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get external link value\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to get external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
@@ -1817,8 +1815,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
const char *targname;
if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
- error_msg(progname, "unable to unpack external link value\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
@@ -1950,20 +1948,20 @@ dump_named_datatype(hid_t tid, const char *name)
if ((tcpl_id = H5Tget_create_plist(tid)) < 0)
{
- error_msg(progname, "error in getting creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the creation properties for attributes */
if (H5Pget_attr_creation_order(tcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(H5Pclose(tcpl_id) < 0) {
- error_msg(progname, "error in closing creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in closing creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -1982,9 +1980,9 @@ dump_named_datatype(hid_t tid, const char *name)
found_obj = search_obj(type_table, oinfo.addr);
if (found_obj == NULL) {
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
else if (found_obj->displayed) {
@@ -2007,14 +2005,14 @@ dump_named_datatype(hid_t tid, const char *name)
if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2056,27 +2054,27 @@ dump_group(hid_t gid, const char *name)
if ((gcpl_id = H5Gget_create_plist(gid)) < 0)
{
- error_msg(progname, "error in getting group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties for attributes */
if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties */
if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(H5Pclose(gcpl_id) < 0) {
- error_msg(progname, "error in closing group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -2118,9 +2116,9 @@ dump_group(hid_t gid, const char *name)
if (found_obj == NULL) {
indentation(indent);
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
else if (found_obj->displayed) {
indentation(indent);
@@ -2133,14 +2131,14 @@ dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2164,14 +2162,14 @@ dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2218,15 +2216,15 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
if ((dcpl_id = H5Dget_create_plist(did)) < 0)
{
- error_msg(progname, "error in getting creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the creation properties for attributes */
if (H5Pget_attr_creation_order(dcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
indentation(indent);
@@ -2280,14 +2278,14 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2598,8 +2596,8 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
if (status == FAIL) {
indentation(indent + COL);
- error_msg(progname, "unable to print data\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to print data\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
indentation(indent);
@@ -3569,10 +3567,10 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
begin_obj(dump_header_format->datasetbegin, real_name,
dump_header_format->datasetblockbegin);
indentation(COL);
- error_msg(progname, "unable to open dataset \"%s\"\n", real_name);
+ error_msg("unable to open dataset \"%s\"\n", real_name);
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
return;
} /* end if */
@@ -3639,8 +3637,8 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
if ( sset->stride[i] < sset->block[i] )
{
- error_msg(progname, "wrong subset selection; blocks overlap\n");
- d_status = EXIT_FAILURE;
+ error_msg("wrong subset selection; blocks overlap\n");
+ h5tools_setstatus(EXIT_FAILURE);
return;
}
@@ -3674,13 +3672,13 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
}
}
else
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
else
dump_dataset(dsetid, real_name, sset);
if(H5Dclose(dsetid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
/*-------------------------------------------------------------------------
@@ -3716,9 +3714,9 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch
{
begin_obj(dump_header_format->groupbegin, real_name, dump_header_format->groupblockbegin);
indentation(COL);
- error_msg(progname, "unable to open group \"%s\"\n", real_name);
+ error_msg("unable to open group \"%s\"\n", real_name);
end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
}
else
@@ -3736,7 +3734,7 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch
dump_group(gid, real_name);
if(H5Gclose(gid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
} /* end else */
} /* end handle_groups() */
@@ -3760,11 +3758,11 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co
H5L_info_t linfo;
if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get link info from \"%s\"\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("unable to get link info from \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
} else if(linfo.type == H5L_TYPE_HARD) {
- error_msg(progname, "\"%s\" is a hard link\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("\"%s\" is a hard link\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
} else {
char *buf = HDmalloc(linfo.u.val_size);
@@ -3776,9 +3774,9 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co
if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0)
printf("LINKTARGET \"%s\"\n", buf);
else {
- error_msg(progname, "h5dump error: unable to get link value for \"%s\"\n",
+ error_msg("h5dump error: unable to get link value for \"%s\"\n",
links);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
end_obj(dump_header_format->softlinkend,
dump_header_format->softlinkblockend);
@@ -3802,12 +3800,12 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co
indentation(COL);
printf("TARGETPATH \"%s\"\n", elink_path);
} else {
- error_msg(progname, "h5dump error: unable to unpack external link value for \"%s\"\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
- error_msg(progname, "h5dump error: unable to get external link value for \"%s\"\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("h5dump error: unable to get external link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
}
end_obj(dump_header_format->extlinkend,
dump_header_format->extlinkblockend);
@@ -3883,10 +3881,10 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const
begin_obj(dump_header_format->datatypebegin, real_name,
dump_header_format->datatypeblockbegin);
indentation(COL);
- error_msg(progname, "unable to open datatype \"%s\"\n", real_name);
+ error_msg("unable to open datatype \"%s\"\n", real_name);
end_obj(dump_header_format->datatypeend,
dump_header_format->datatypeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
}
else
@@ -3903,7 +3901,7 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const
dump_named_datatype(type_id, real_name);
if(H5Tclose(type_id) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
}
@@ -3935,7 +3933,7 @@ parse_command_line(int argc, const char *argv[])
/* no arguments */
if (argc == 1) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
@@ -3985,7 +3983,7 @@ parse_start:
display_char = TRUE;
break;
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
case 'w':
@@ -4061,13 +4059,13 @@ parse_start:
case 'o':
if ( bin_output ) {
if (set_output_file(opt_arg, 1) < 0) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
else {
if (set_output_file(opt_arg, 0) < 0) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -4081,7 +4079,7 @@ parse_start:
if ( opt_arg != NULL) {
if ( ( bin_form = set_binary_form(opt_arg)) < 0) {
/* failed to set binary form */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -4089,7 +4087,7 @@ parse_start:
if (outfname!=NULL) {
if (set_output_file(outfname, 1) < 0) {
/* failed to set output file */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
@@ -4100,7 +4098,7 @@ parse_start:
case 'q':
if ( ( sort_by = set_sort_by(opt_arg)) < 0) {
/* failed to set "sort by" form */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
break;
@@ -4108,7 +4106,7 @@ parse_start:
case 'z':
if ( ( sort_order = set_sort_order(opt_arg)) < 0) {
/* failed to set "sort order" form */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
break;
@@ -4146,7 +4144,7 @@ parse_start:
/* specify XML namespace (default="hdf5:"), or none */
/* To Do: check format of this value? */
if (!useschema) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
if (strcmp(opt_arg,":") == 0) {
@@ -4165,7 +4163,7 @@ parse_start:
struct subset_t *s;
if (!last_was_dset) {
- error_msg(progname,
+ error_msg(h5tools_getprogname(),
"option `-%c' can only be used after --dataset option\n",
opt);
leave(EXIT_FAILURE);
@@ -4213,11 +4211,11 @@ end_collect:
/** end subsetting parameters **/
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
case '?':
default:
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -4225,8 +4223,8 @@ end_collect:
parse_end:
/* check for file name to be processed */
if (argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
return hand;
@@ -4320,6 +4318,8 @@ main(int argc, const char *argv[])
int i;
unsigned u;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
dump_header_format = &standardformat;
dump_function_table = &ddl_function_table;
@@ -4333,43 +4333,43 @@ main(int argc, const char *argv[])
if ( bin_output && outfname == NULL )
{
- error_msg(progname, "binary output requires a file name, use -o <filename>\n");
+ error_msg("binary output requires a file name, use -o <filename>\n");
leave(EXIT_FAILURE);
}
/* Check for conflicting options */
if (doxml) {
if (!display_all) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"to display selected objects");
leave(EXIT_FAILURE);
} else if (display_bb) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--boot-block");
leave(EXIT_FAILURE);
} else if (display_oid == 1) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--object-ids");
leave(EXIT_FAILURE);
} else if (display_char == TRUE) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--string");
leave(EXIT_FAILURE);
} else if (usingdasho) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--output");
leave(EXIT_FAILURE);
}
} else {
if (xml_dtd_uri) {
- warn_msg(progname, "option \"%s\" only applies with XML: %s\n",
+ warn_msg("option \"%s\" only applies with XML: %s\n",
"--xml-dtd", xml_dtd_uri);
}
}
if (argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
fname = HDstrdup(argv[opt_ind]);
@@ -4377,7 +4377,7 @@ main(int argc, const char *argv[])
fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
if (fid < 0) {
- error_msg(progname, "unable to open file \"%s\"\n", fname);
+ error_msg("unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
}
@@ -4403,7 +4403,7 @@ main(int argc, const char *argv[])
}
} else {
if (useschema && strcmp(xmlnsprefix,"")) {
- error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
+ error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
leave(EXIT_FAILURE);
}
}
@@ -4412,15 +4412,15 @@ main(int argc, const char *argv[])
/* Get object info for root group */
if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) {
- error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* Initialize object tables */
if(table_list_add(fid, oi.fileno) < 0) {
- error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
group_table = table_list.tables[0].group_table;
@@ -4482,8 +4482,8 @@ main(int argc, const char *argv[])
{
if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
{
- error_msg(progname, "unable to open root group\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to open root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
else
{
@@ -4494,8 +4494,8 @@ main(int argc, const char *argv[])
if(H5Gclose(gid) < 0)
{
- error_msg(progname, "unable to close root group\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to close root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -4504,8 +4504,8 @@ main(int argc, const char *argv[])
{
/* Note: this option is not supported for XML */
if(doxml) {
- error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
} /* end if */
@@ -4525,7 +4525,7 @@ done:
table_list_free();
if (H5Fclose(fid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
free_handler(hand, argc);
@@ -4536,7 +4536,7 @@ done:
H5Eset_auto2(H5E_DEFAULT, func, edata);
- leave(d_status);
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
@@ -4949,7 +4949,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
free(dtxid);
} else {
printf("<!-- h5dump error: unknown committed type. -->\n");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
@@ -5253,7 +5253,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
default:
printf("<!-- unknown datatype -->");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
break;
}
} /* end else */
@@ -5635,7 +5635,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t UNUSED *info,
printf("<!-- h5dump error: unable to open attribute. -->\n");
indentation(indent);
printf("</%sAttribute>\n", xmlnsprefix );
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return FAIL;
}
}
@@ -5710,9 +5710,9 @@ xml_dump_named_datatype(hid_t type, const char *name)
if (found_obj == NULL) {
indentation(indent);
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
} else if(found_obj->displayed) {
/* We have already printed this named datatype, print it as a
@@ -5791,27 +5791,27 @@ xml_dump_group(hid_t gid, const char *name)
if ((gcpl_id = H5Gget_create_plist(gid)) < 0)
{
- error_msg(progname, "error in getting group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties for attributes */
if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties */
if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(H5Pclose(gcpl_id) < 0) {
- error_msg(progname, "error in closing group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(HDstrcmp(name, "/") == 0) {
@@ -5843,9 +5843,9 @@ xml_dump_group(hid_t gid, const char *name)
if (found_obj == NULL) {
indentation(indent);
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
} else {
char *t_name = xml_escape_the_name(name);
char *grpxid = malloc(100);
@@ -5910,14 +5910,14 @@ xml_dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -5982,14 +5982,14 @@ xml_dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -6648,14 +6648,14 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -7088,7 +7088,7 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname)
handle_datatypes(group, linkname, NULL, 0, objname);
break;
default:
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
indent -= 2*COL;
@@ -7103,7 +7103,7 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname)
} /* end if */
if (H5Idec_ref(oid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return SUCCEED;
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 45aa53c..6b75aa3 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -28,6 +28,9 @@
#include "H5private.h"
#include "h5tools.h"
+/* Name of tool */
+#define PROGRAMNAME "h5dumpgentest"
+
#define FILE1 "tgroup.h5"
#define FILE2 "tdset.h5"
#define FILE3 "tattr.h5"
diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c
index 24428cb..82b92d2 100755
--- a/tools/h5import/h5import.c
+++ b/tools/h5import/h5import.c
@@ -23,6 +23,9 @@
#include "h5tools_utils.h"
+/* Name of tool */
+#define PROGRAMNAME "h5import"
+
int main(int argc, char *argv[])
{
struct Options opt;
@@ -42,6 +45,9 @@ int main(int argc, char *argv[])
const char *err8 = "Invalid size of data - %s.\n";
const char *err9 = "Cannot specify more than 30 input files in one call to h5import.\n";
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
(void)HDsetvbuf(stderr, (char *) NULL, _IOLBF, 0);
(void)HDsetvbuf(stdout, (char *) NULL, _IOLBF, 0);
diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c
index 2fb5833..293aa17 100644
--- a/tools/h5jam/getub.c
+++ b/tools/h5jam/getub.c
@@ -28,7 +28,8 @@ void parse_command_line (int argc, const char *argv[]);
#define TRUE 1
#define FALSE 0
-static const char *progname="getub";
+/* Name of tool */
+#define PROGRAMNAME "getub"
char *nbytes = NULL;
static const char *s_opts = "c:"; /* add more later ? */
@@ -89,15 +90,15 @@ parse_command_line (int argc, const char *argv[])
break;
case '?':
default:
- usage (progname);
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
}
if (argc <= opt_ind)
{
- error_msg (progname, "missing file name\n");
- usage (progname);
+ error_msg("missing file name\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
}
@@ -111,19 +112,22 @@ main (int argc, const char *argv[])
long res;
char *buf;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
parse_command_line (argc, argv);
if (nbytes == NULL)
{
/* missing arg */
- error_msg (progname, "missing size\n");
- usage (progname);
+ error_msg("missing size\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
if (argc <= (opt_ind))
{
- error_msg (progname, "missing file name\n");
- usage (progname);
+ error_msg("missing file name\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
filename = HDstrdup (argv[opt_ind]);
@@ -133,15 +137,15 @@ main (int argc, const char *argv[])
if (res == EOF)
{
/* fail */
- error_msg (progname, "missing file name\n");
- usage (progname);
+ error_msg("missing file name\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
fd = HDopen (filename, O_RDONLY, 0);
if (fd < 0)
{
- error_msg (progname, "can't open file %s\n", filename);
+ error_msg("can't open file %s\n", filename);
exit (EXIT_FAILURE);
}
diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c
index cceed75..17b1384 100644
--- a/tools/h5jam/h5jam.c
+++ b/tools/h5jam/h5jam.c
@@ -24,6 +24,9 @@
#include "H5private.h"
#include "h5tools_utils.h"
+/* Name of tool */
+#define PROGRAMNAME "h5jam"
+
#define TRUE 1
#define FALSE 0
@@ -32,8 +35,6 @@ hsize_t compute_user_block_size (hsize_t);
hsize_t copy_some_to_file (int, int, hsize_t, hsize_t, ssize_t);
void parse_command_line (int, const char *[]);
-const char *progname = "h5jam";
-int d_status = EXIT_SUCCESS;
int do_clobber = FALSE;
char *output_file = NULL;
char *input_file = NULL;
@@ -131,14 +132,14 @@ parse_command_line (int argc, const char *argv[])
do_clobber = TRUE;
break;
case 'h':
- usage (progname);
+ usage (h5tools_getprogname());
exit (EXIT_SUCCESS);
case 'V':
- print_version (progname);
+ print_version (h5tools_getprogname());
exit (EXIT_SUCCESS);
case '?':
default:
- usage (progname);
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
}
@@ -180,6 +181,9 @@ main (int argc, const char *argv[])
struct stat sbuf2;
int res;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -189,16 +193,16 @@ main (int argc, const char *argv[])
if (ub_file == NULL)
{
/* no user block */
- error_msg (progname, "no user block file name\n");
- usage (progname);
+ error_msg("no user block file name\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
if (input_file == NULL)
{
/* no user block */
- error_msg (progname, "no HDF5 file\n");
- usage (progname);
+ error_msg("no HDF5 file\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
@@ -206,7 +210,7 @@ main (int argc, const char *argv[])
if (testval <= 0)
{
- error_msg (progname, "Input HDF5 file is not HDF \"%s\"\n", input_file);
+ error_msg("Input HDF5 file is not HDF \"%s\"\n", input_file);
exit (EXIT_FAILURE);
}
@@ -214,14 +218,14 @@ main (int argc, const char *argv[])
if (ifile < 0)
{
- error_msg (progname, "Can't open input HDF5 file \"%s\"\n", input_file);
+ error_msg("Can't open input HDF5 file \"%s\"\n", input_file);
exit (EXIT_FAILURE);
}
plist = H5Fget_create_plist (ifile);
if (plist < 0)
{
- error_msg (progname, "Can't get file creation plist for file \"%s\"\n",
+ error_msg("Can't get file creation plist for file \"%s\"\n",
input_file);
exit (EXIT_FAILURE);
}
@@ -229,7 +233,7 @@ main (int argc, const char *argv[])
status = H5Pget_userblock (plist, &usize);
if (status < 0)
{
- error_msg (progname, "Can't get user block for file \"%s\"\n",
+ error_msg("Can't get user block for file \"%s\"\n",
input_file);
exit (EXIT_FAILURE);
}
@@ -241,7 +245,7 @@ main (int argc, const char *argv[])
if (ufid < 0)
{
- error_msg (progname, "unable to open user block file \"%s\"\n",
+ error_msg("unable to open user block file \"%s\"\n",
ub_file);
exit (EXIT_FAILURE);
}
@@ -250,7 +254,7 @@ main (int argc, const char *argv[])
if (res < 0)
{
- error_msg (progname, "Can't stat file \"%s\"\n", ub_file);
+ error_msg("Can't stat file \"%s\"\n", ub_file);
exit (EXIT_FAILURE);
}
@@ -260,7 +264,7 @@ main (int argc, const char *argv[])
if (h5fid < 0)
{
- error_msg (progname, "unable to open HDF5 file for read \"%s\"\n",
+ error_msg("unable to open HDF5 file for read \"%s\"\n",
input_file);
exit (EXIT_FAILURE);
}
@@ -269,7 +273,7 @@ main (int argc, const char *argv[])
if (res < 0)
{
- error_msg (progname, "Can't stat file \"%s\"\n", input_file);
+ error_msg("Can't stat file \"%s\"\n", input_file);
exit (EXIT_FAILURE);
}
@@ -281,7 +285,7 @@ main (int argc, const char *argv[])
if (ofid < 0)
{
- error_msg (progname, "unable to open output file \"%s\"\n",
+ error_msg("unable to open output file \"%s\"\n",
output_file);
exit (EXIT_FAILURE);
}
@@ -292,7 +296,7 @@ main (int argc, const char *argv[])
if (ofid < 0)
{
- error_msg (progname, "unable to create output file \"%s\"\n",
+ error_msg("unable to create output file \"%s\"\n",
output_file);
exit (EXIT_FAILURE);
}
@@ -346,7 +350,7 @@ main (int argc, const char *argv[])
HDclose (h5fid);
HDclose (ofid);
- return d_status;
+ return h5tools_getstatus();
}
/*-------------------------------------------------------------------------
@@ -395,7 +399,7 @@ copy_some_to_file (int infid, int outfid, hsize_t startin, hsize_t startout,
if (startin > startout)
{
/* this case is prohibited */
- error_msg (progname, "copy_some_to_file: panic: startin > startout?\n");
+ error_msg("copy_some_to_file: panic: startin > startout?\n");
exit (EXIT_FAILURE);
}
@@ -405,7 +409,7 @@ copy_some_to_file (int infid, int outfid, hsize_t startin, hsize_t startout,
if (res < 0)
{
- error_msg (progname, "Can't stat file \n");
+ error_msg("Can't stat file \n");
exit (EXIT_FAILURE);
}
diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c
index 5e4d864..8e31ce1 100644
--- a/tools/h5jam/h5unjam.c
+++ b/tools/h5jam/h5unjam.c
@@ -26,6 +26,9 @@
#include "H5private.h"
#include "h5tools_utils.h"
+/* Name of tool */
+#define PROGRAMNAME "h5unjam"
+
#define TRUE 1
#define FALSE 0
#define COPY_BUF_SIZE 1024
@@ -34,8 +37,6 @@ hsize_t write_pad( int , hsize_t );
hsize_t compute_pad( hsize_t );
herr_t copy_to_file( int , int , ssize_t, ssize_t );
-const char *progname = "h5unjam";
-int d_status = EXIT_SUCCESS;
int do_delete = FALSE;
char *output_file = NULL;
char *input_file = NULL;
@@ -125,14 +126,14 @@ parse_command_line(int argc, const char *argv[])
do_delete = TRUE;
break;
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
exit(EXIT_SUCCESS);
case 'V':
- print_version (progname);
+ print_version (h5tools_getprogname());
exit (EXIT_SUCCESS);
case '?':
default:
- usage(progname);
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -140,8 +141,8 @@ parse_command_line(int argc, const char *argv[])
/* check for file name to be processed */
/*
if (argc <= opt_ind+2) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
*/
@@ -178,6 +179,9 @@ main(int argc, const char *argv[])
int res;
struct stat sbuf;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -187,32 +191,32 @@ main(int argc, const char *argv[])
testval = H5Fis_hdf5(input_file);
if (testval <= 0) {
- error_msg(progname, "Input HDF5 file is not HDF \"%s\"\n", input_file);
+ error_msg("Input HDF5 file is not HDF \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
ifile = H5Fopen(input_file, H5F_ACC_RDONLY , H5P_DEFAULT);
if (ifile < 0) {
- error_msg(progname, "Can't open input HDF5 file \"%s\"\n", input_file);
+ error_msg("Can't open input HDF5 file \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
plist = H5Fget_create_plist(ifile);
if (plist < 0) {
- error_msg(progname, "Can't get file creation plist for file \"%s\"\n", input_file);
+ error_msg("Can't get file creation plist for file \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
status = H5Pget_userblock(plist, & usize );
if (status < 0) {
- error_msg(progname, "Can't get user block for file \"%s\"\n", input_file);
+ error_msg("Can't get user block for file \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
if (usize == 0) {
/* no user block to remove: message? */
- error_msg(progname, "\"%s\" has no user block: no change to file\n", input_file);
+ error_msg("\"%s\" has no user block: no change to file\n", input_file);
exit(EXIT_SUCCESS);
}
@@ -220,7 +224,7 @@ main(int argc, const char *argv[])
res = stat(input_file, &sbuf);
if (res < 0) {
- error_msg(progname, "Can't stat file \"%s\"\n", input_file);
+ error_msg("Can't stat file \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
@@ -229,12 +233,12 @@ main(int argc, const char *argv[])
ifid = HDopen(input_file,O_RDONLY,0);
if (ifid < 0) {
- error_msg(progname, "unable to open input HDF5 file \"%s\"\n", input_file);
+ error_msg("unable to open input HDF5 file \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
if (do_delete && (ub_file != NULL)) {
- error_msg(progname, "??\"%s\"\n", ub_file);
+ error_msg("??\"%s\"\n", ub_file);
exit(EXIT_FAILURE);
}
@@ -245,7 +249,7 @@ main(int argc, const char *argv[])
ufid = HDopen(ub_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 );
if (ufid < 0) {
- error_msg(progname, "unable to open user block file for output\"%s\"\n", ub_file);
+ error_msg("unable to open user block file for output\"%s\"\n", ub_file);
exit(EXIT_FAILURE);
}
}
@@ -254,14 +258,14 @@ main(int argc, const char *argv[])
h5fid = HDopen(input_file,O_WRONLY, 0);
if (h5fid < 0) {
- error_msg(progname, "unable to open output HDF5 file \"%s\"\n", input_file);
+ error_msg("unable to open output HDF5 file \"%s\"\n", input_file);
exit(EXIT_FAILURE);
}
} else {
h5fid = HDopen(output_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 );
if (h5fid < 0) {
- error_msg(progname, "unable to open output HDF5 file \"%s\"\n", output_file);
+ error_msg("unable to open output HDF5 file \"%s\"\n", output_file);
exit(EXIT_FAILURE);
}
}
@@ -270,7 +274,7 @@ main(int argc, const char *argv[])
/* copy from 0 to 'usize - 1' into ufid */
if (!do_delete) {
if(copy_to_file(ifid, ufid, 0, (ssize_t) usize) < 0) {
- error_msg(progname, "unable to copy user block to output file \"%s\"\n", ub_file);
+ error_msg("unable to copy user block to output file \"%s\"\n", ub_file);
exit(EXIT_FAILURE);
}
}
@@ -279,7 +283,7 @@ main(int argc, const char *argv[])
* starting at end of user block if present
*/
if(copy_to_file(ifid, h5fid, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) {
- error_msg(progname, "unable to copy hdf5 data to output file \"%s\"\n", output_file);
+ error_msg("unable to copy hdf5 data to output file \"%s\"\n", output_file);
exit(EXIT_FAILURE);
}
@@ -288,7 +292,7 @@ main(int argc, const char *argv[])
HDclose(h5fid);
HDclose(ifid);
- return d_status;
+ return h5tools_getstatus();
}
/*
diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c
index d39b958..2cf30e2 100644
--- a/tools/h5jam/tellub.c
+++ b/tools/h5jam/tellub.c
@@ -26,7 +26,8 @@
#define TRUE 1
#define FALSE 0
-const char *progname = "tellub";
+/* Name of tool */
+#define PROGRAMNAME "tellub"
/*
* Command-line options: The user can specify short or long-named
@@ -91,11 +92,11 @@ parse_command_line (int argc, const char *argv[])
switch ((char) opt)
{
case 'h':
- usage (progname);
+ usage (h5tools_getprogname());
exit (EXIT_SUCCESS);
case '?':
default:
- usage (progname);
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
}
@@ -103,8 +104,8 @@ parse_command_line (int argc, const char *argv[])
/* 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());
exit (EXIT_FAILURE);
}
}
@@ -135,6 +136,9 @@ main (int argc, const char *argv[])
herr_t status;
hid_t plist;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable error reporting */
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -143,8 +147,8 @@ main (int argc, const char *argv[])
if (argc <= (opt_ind))
{
- error_msg (progname, "missing file name\n");
- usage (progname);
+ error_msg("missing file name\n");
+ usage (h5tools_getprogname());
return (EXIT_FAILURE);
}
@@ -154,7 +158,7 @@ main (int argc, const char *argv[])
if (testval <= 0)
{
- error_msg (progname, "Input HDF5 file is not HDF \"%s\"\n", ifname);
+ error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname);
return (EXIT_FAILURE);
}
@@ -162,14 +166,14 @@ main (int argc, const char *argv[])
if (ifile < 0)
{
- error_msg (progname, "Can't open input HDF5 file \"%s\"\n", ifname);
+ error_msg("Can't open input HDF5 file \"%s\"\n", ifname);
return (EXIT_FAILURE);
}
plist = H5Fget_create_plist (ifile);
if (plist < 0)
{
- error_msg (progname, "Can't get file creation plist for file \"%s\"\n",
+ error_msg("Can't get file creation plist for file \"%s\"\n",
ifname);
return (EXIT_FAILURE);
}
@@ -177,7 +181,7 @@ main (int argc, const char *argv[])
status = H5Pget_userblock (plist, &usize);
if (status < 0)
{
- error_msg (progname, "Can't get user block for file \"%s\"\n", ifname);
+ error_msg("Can't get user block for file \"%s\"\n", ifname);
return (EXIT_FAILURE);
}
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index ab3a110..c856642 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -29,6 +29,9 @@
#include "h5tools_utils.h"
#include "h5trav.h"
+/* Name of tool */
+#define PROGRAMNAME "h5ls"
+
#define NAME_BUF_SIZE 2048
/* Struct to keep track of external link targets visited */
@@ -88,9 +91,6 @@ static struct dispatch_t {
static void display_type(hid_t type, int ind);
static herr_t visit_obj(hid_t file, const char *oname, iter_t *iter);
-const char *progname="h5ls";
-int d_status;
-
/*-------------------------------------------------------------------------
* Function: usage
@@ -135,7 +135,7 @@ usage: %s [OPTIONS] [OBJECTS...]\n\
within the file then the contents of the root group are displayed).\n\
The file name may include a printf(3C) integer format such as\n\
\"%%05d\" to open a file family.\n",
- progname);
+ h5tools_getprogname());
}
@@ -2182,6 +2182,9 @@ main(int argc, const char *argv[])
const char *preferred_driver = NULL;
int err_openfile = 0;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Initialize h5tools lib */
h5tools_init();
@@ -2249,7 +2252,7 @@ main(int argc, const char *argv[])
} else if(!HDstrcmp(argv[argno], "--verbose")) {
verbose_g++;
} else if(!HDstrcmp(argv[argno], "--version")) {
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
} else if(!HDstrcmp(argv[argno], "--hexdump")) {
hexdump_g = TRUE;
@@ -2325,7 +2328,7 @@ main(int argc, const char *argv[])
break;
case 'V': /* --version */
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
case 'x': /* --hexdump */
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 8d10a57..da1fbf3 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -22,10 +22,6 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-
-extern char *progname;
-
-
/*-------------------------------------------------------------------------
* File: h5repack.c
* Purpose: Public API functions
@@ -160,7 +156,7 @@ int h5repack_addfilter(const char* str,
if(options->n_filter_g > H5_REPACK_MAX_NFILTERS)
{
- error_msg(progname, "maximum number of filters exceeded for <%s>\n", str);
+ error_msg("maximum number of filters exceeded for <%s>\n", str);
free(obj_list);
return -1;
}
@@ -198,7 +194,7 @@ int h5repack_addlayout(const char* str,
init_packobject(&pack);
if (options->all_layout==1){
- error_msg(progname, "invalid layout input: 'all' option \
+ error_msg("invalid layout input: 'all' option \
is present with other objects <%s>\n",str);
return -1;
}
@@ -617,7 +613,7 @@ static int check_options(pack_opt_t *options)
break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
- error_msg(progname, "invalid layout\n");
+ error_msg("invalid layout\n");
return -1;
default:
strcpy(slayout,"invalid layout\n");
@@ -658,7 +654,7 @@ static int check_options(pack_opt_t *options)
if (options->all_layout==1 && has_ck)
{
- error_msg(progname, "invalid chunking input: 'all' option\
+ error_msg("invalid chunking input: 'all' option\
is present with other objects\n");
return -1;
}
@@ -720,7 +716,7 @@ static int check_options(pack_opt_t *options)
if (options->all_filter==1 && has_cp)
{
- error_msg(progname, "invalid compression input: 'all' option\
+ error_msg("invalid compression input: 'all' option\
is present with other objects\n");
return -1;
}
@@ -732,24 +728,24 @@ static int check_options(pack_opt_t *options)
if (options->grp_compact < 0)
{
- error_msg(progname, "invalid maximum number of links to store as header messages\n");
+ error_msg("invalid maximum number of links to store as header messages\n");
return -1;
}
if (options->grp_indexed < 0)
{
- error_msg(progname, "invalid minimum number of links to store in the indexed format\n");
+ error_msg("invalid minimum number of links to store in the indexed format\n");
return -1;
}
if (options->grp_indexed > options->grp_compact)
{
- error_msg(progname, "minimum indexed size is greater than the maximum compact size\n");
+ error_msg("minimum indexed size is greater than the maximum compact size\n");
return -1;
}
for (i=0; i<8; i++)
{
if (options->msg_size[i]<0)
{
- error_msg(progname, "invalid shared message size\n");
+ error_msg("invalid shared message size\n");
return -1;
}
}
@@ -771,7 +767,7 @@ static int check_options(pack_opt_t *options)
if ( options->ublock_filename == NULL && options->ublock_size != 0 )
{
- error_msg(progname, "file name missing for user block\n",
+ error_msg("file name missing for user block\n",
options->ublock_filename);
return -1;
}
@@ -784,7 +780,7 @@ static int check_options(pack_opt_t *options)
if ( options->alignment == 0 && options->threshold != 0 )
{
- error_msg(progname, "alignment for H5Pset_alignment missing\n");
+ error_msg("alignment for H5Pset_alignment missing\n");
return -1;
}
@@ -856,7 +852,7 @@ static int check_objects(const char* fname,
/* the input object names are present in the file and are valid */
if(h5trav_getindext(name, travt) < 0)
{
- error_msg(progname, "%s Could not find <%s> in file <%s>. Exiting...\n",
+ error_msg("%s Could not find <%s> in file <%s>. Exiting...\n",
(options->verbose?"\n":""),name,fname);
goto out;
}
@@ -978,7 +974,7 @@ static const char* get_sfilter(H5Z_filter_t filtn)
else if (filtn==H5Z_FILTER_SCALEOFFSET)
return "SOFF";
else {
- error_msg(progname, "input error in filter type\n");
+ error_msg("input error in filter type\n");
exit(EXIT_FAILURE);
}
}
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 12fdabc..c3475aa 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -30,7 +30,6 @@
* globals
*-------------------------------------------------------------------------
*/
-extern char *progname;
/*-------------------------------------------------------------------------
* macros
@@ -90,7 +89,7 @@ int copy_objects(const char* fnamein,
*/
if((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
{
- error_msg(progname, "<%s>: %s\n", fnamein, H5FOPENERROR );
+ error_msg("<%s>: %s\n", fnamein, H5FOPENERROR );
goto out;
}
@@ -100,13 +99,13 @@ int copy_objects(const char* fnamein,
if((fcpl_in = H5Fget_create_plist(fidin)) < 0)
{
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto out;
}
if(H5Pget_userblock(fcpl_in, &ub_size) < 0)
{
- error_msg(progname, "failed to retrieve userblock size\n");
+ error_msg("failed to retrieve userblock size\n");
goto out;
}
@@ -114,7 +113,7 @@ int copy_objects(const char* fnamein,
{
if(H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0)
{
- error_msg(progname, "failed to retrieve file space strategy\n");
+ error_msg("failed to retrieve file space strategy\n");
goto out;
}
}
@@ -123,14 +122,14 @@ int copy_objects(const char* fnamein,
{
if(H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0)
{
- error_msg(progname, "failed to retrieve file space threshold\n");
+ error_msg("failed to retrieve file space threshold\n");
goto out;
}
}
if(H5Pclose(fcpl_in) < 0)
{
- error_msg(progname, "failed to close property list\n");
+ error_msg("failed to close property list\n");
goto out;
}
}
@@ -141,7 +140,7 @@ int copy_objects(const char* fnamein,
/* Create file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
- error_msg(progname, "fail to create a file creation property list\n");
+ error_msg("fail to create a file creation property list\n");
goto out;
}
@@ -149,7 +148,7 @@ int copy_objects(const char* fnamein,
{
if(H5Pset_userblock(fcpl, ub_size) < 0)
{
- error_msg(progname, "failed to set non-default userblock size\n");
+ error_msg("failed to set non-default userblock size\n");
goto out;
}
}
@@ -162,7 +161,7 @@ int copy_objects(const char* fnamein,
/* (So that it is created in "dense storage" form) */
if(H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0)
{
- error_msg(progname, "fail to adjust group creation parameters for root group\n");
+ error_msg("fail to adjust group creation parameters for root group\n");
goto out;
}
@@ -204,7 +203,7 @@ int copy_objects(const char* fnamein,
{
if(H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0)
{
- error_msg(progname, "fail to set the number of shared object header message indexes\n");
+ error_msg("fail to set the number of shared object header message indexes\n");
goto out;
}
@@ -212,7 +211,7 @@ int copy_objects(const char* fnamein,
for(i = 0; i < (nindex - 1); i++)
{
if(H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) {
- error_msg(progname, "fail to configure the specified shared object header message index\n");
+ error_msg("fail to configure the specified shared object header message index\n");
goto out;
} /* end if */
} /* end for */
@@ -221,13 +220,13 @@ int copy_objects(const char* fnamein,
/* Create file access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
{
- error_msg(progname, "Could not create file access property list\n");
+ error_msg("Could not create file access property list\n");
goto out;
} /* end if */
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
{
- error_msg(progname, "Could not set property for using latest version of the format\n");
+ error_msg("Could not set property for using latest version of the format\n");
goto out;
} /* end if */
} /* end if */
@@ -254,7 +253,7 @@ int copy_objects(const char* fnamein,
/* set user block size */
if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
{
- error_msg(progname, "failed to set userblock size\n");
+ error_msg("failed to set userblock size\n");
goto out;
}
@@ -266,14 +265,14 @@ int copy_objects(const char* fnamein,
/* create a file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
- error_msg(progname, "fail to create a file creation property list\n");
+ error_msg("fail to create a file creation property list\n");
goto out;
}
/* set user block size */
if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
{
- error_msg(progname, "failed to set userblock size\n");
+ error_msg("failed to set userblock size\n");
goto out;
}
@@ -298,7 +297,7 @@ int copy_objects(const char* fnamein,
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
{
- error_msg(progname, "failed to set alignment\n");
+ error_msg("failed to set alignment\n");
goto out;
}
@@ -310,13 +309,13 @@ int copy_objects(const char* fnamein,
/* create a file access property list */
if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
{
- error_msg(progname, "Could not create file access property list\n");
+ error_msg("Could not create file access property list\n");
goto out;
}
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
{
- error_msg(progname, "failed to set alignment\n");
+ error_msg("failed to set alignment\n");
goto out;
}
@@ -330,7 +329,7 @@ int copy_objects(const char* fnamein,
/* set file space strategy and free space threshold */
if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
{
- error_msg(progname, "failed to set file space strategy & threshold\n");
+ error_msg("failed to set file space strategy & threshold\n");
goto out;
}
}
@@ -339,14 +338,14 @@ int copy_objects(const char* fnamein,
/* create a file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
- error_msg(progname, "fail to create a file creation property list\n");
+ error_msg("fail to create a file creation property list\n");
goto out;
}
/* set file space strategy and free space threshold */
if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
{
- error_msg(progname, "failed to set file space strategy & threshold \n");
+ error_msg("failed to set file space strategy & threshold \n");
goto out;
}
}
@@ -363,7 +362,7 @@ int copy_objects(const char* fnamein,
if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0)
{
- error_msg(progname, "<%s>: Could not create file\n", fnameout );
+ error_msg("<%s>: Could not create file\n", fnameout );
goto out;
}
@@ -376,7 +375,7 @@ int copy_objects(const char* fnamein,
{
if ( copy_user_block( options->ublock_filename, fnameout, options->ublock_size) < 0 )
{
- error_msg(progname, "Could not copy user block. Exiting...\n");
+ error_msg("Could not copy user block. Exiting...\n");
goto out;
}
@@ -400,7 +399,7 @@ int copy_objects(const char* fnamein,
*/
if(do_copy_objects(fidin, fidout, travt, options) < 0)
{
- error_msg(progname, "<%s>: Could not copy data to: %s\n", fnamein, fnameout);
+ error_msg("<%s>: Could not copy data to: %s\n", fnamein, fnameout);
goto out;
} /* end if */
@@ -442,7 +441,7 @@ int copy_objects(const char* fnamein,
{
if ( copy_user_block(fnamein, fnameout, ub_size) < 0 )
{
- error_msg(progname, "Could not copy user block. Exiting...\n");
+ error_msg("Could not copy user block. Exiting...\n");
goto out;
}
@@ -1406,19 +1405,19 @@ void print_user_block(const char *filename, hid_t fid)
/* get user block size */
if(( fcpl = H5Fget_create_plist(fid)) < 0)
{
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto done;
}
if(H5Pget_userblock(fcpl, &ub_size) < 0)
{
- error_msg(progname, "failed to retrieve userblock size\n");
+ error_msg("failed to retrieve userblock size\n");
goto done;
}
if(H5Pclose(fcpl) < 0)
{
- error_msg(progname, "failed to close property list\n");
+ error_msg("failed to close property list\n");
goto done;
}
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index c7d8b1e..d4a3479 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -14,6 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
+#include "h5test.h"
#include "h5tools.h"
/* number of members in an array */
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index a95c4c4..7d2fc62 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -20,6 +20,8 @@
#include "h5tools_utils.h"
#include "h5repack.h"
+/* Name of tool */
+#define PROGRAMNAME "h5repack"
static void usage(const char *prog);
static void parse_command_line(int argc, const char **argv, pack_opt_t* options);
@@ -27,8 +29,6 @@ static void read_info(const char *filename,pack_opt_t *options);
/* module-scoped variables */
-const char *progname = "h5repack";
-int d_status = EXIT_SUCCESS;
static int has_i_o = 0;
const char *infile = NULL;
const char *outfile = NULL;
@@ -107,6 +107,9 @@ int main(int argc, const char **argv)
pack_opt_t options; /*the global options */
int ret=-1;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* initialize options */
h5repack_init(&options, 0, 0, (hsize_t)0);
@@ -123,8 +126,8 @@ int main(int argc, const char **argv)
if ( strcmp( infile, outfile ) == 0 )
{
- error_msg(progname, "file names cannot be the same\n");
- usage(progname);
+ error_msg("file names cannot be the same\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
@@ -132,8 +135,8 @@ int main(int argc, const char **argv)
else
{
- error_msg(progname, "file names missing\n");
- usage(progname);
+ error_msg("file names missing\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -316,10 +319,10 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
exit(EXIT_SUCCESS);
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
exit(EXIT_SUCCESS);
case 'v':
options->verbose = 1;
@@ -329,7 +332,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* parse the -f filter option */
if (h5repack_addfilter( opt_arg, options)<0)
{
- error_msg(progname, "in parsing filter\n");
+ error_msg("in parsing filter\n");
exit(EXIT_FAILURE);
}
break;
@@ -338,7 +341,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* parse the -l layout option */
if (h5repack_addlayout( opt_arg, options)<0)
{
- error_msg(progname, "in parsing layout\n");
+ error_msg("in parsing layout\n");
exit(EXIT_FAILURE);
}
break;
@@ -349,7 +352,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
options->min_comp = atoi( opt_arg );
if ((int)options->min_comp<=0)
{
- error_msg(progname, "invalid minimum compress size <%s>\n", opt_arg );
+ error_msg("invalid minimum compress size <%s>\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -442,7 +445,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
options->alignment = atol( opt_arg );
if ( options->alignment < 1 )
{
- error_msg(progname, "invalid alignment size\n", opt_arg );
+ error_msg("invalid alignment size\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -461,7 +464,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
else if(!strcmp(strategy, "VFD"))
options->fs_strategy = H5F_FILE_SPACE_VFD;
else {
- error_msg(progname, "invalid file space management strategy\n", opt_arg );
+ error_msg("invalid file space management strategy\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -481,8 +484,8 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* check for file names to be processed */
if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL)
{
- error_msg(progname, "missing file names\n");
- usage(progname);
+ error_msg("missing file names\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -515,7 +518,7 @@ void read_info(const char *filename,
int i, rc=1;
if ((fp = fopen(filename, "r")) == (FILE *)NULL) {
- error_msg(progname, "cannot open options file %s\n", filename);
+ error_msg("cannot open options file %s\n", filename);
exit(EXIT_FAILURE);
}
@@ -552,7 +555,7 @@ void read_info(const char *filename,
comp_info[i-1]='\0'; /*cut the last " */
if (h5repack_addfilter(comp_info,options)==-1){
- error_msg(progname, "could not add compression option\n");
+ error_msg("could not add compression option\n");
exit(EXIT_FAILURE);
}
}
@@ -582,7 +585,7 @@ void read_info(const char *filename,
comp_info[i-1]='\0'; /*cut the last " */
if (h5repack_addlayout(comp_info,options)==-1){
- error_msg(progname, "could not add chunck option\n");
+ error_msg("could not add chunck option\n");
exit(EXIT_FAILURE);
}
}
@@ -591,7 +594,7 @@ void read_info(const char *filename,
*-------------------------------------------------------------------------
*/
else {
- error_msg(progname, "bad file format for %s", filename);
+ error_msg("bad file format for %s", filename);
exit(EXIT_FAILURE);
}
}
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index 7c87359..50f97bd 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -18,8 +18,6 @@
#include "h5repack.h"
#include "h5tools_utils.h"
-extern char *progname;
-
/*-------------------------------------------------------------------------
* Function: init_packobject
*
@@ -67,7 +65,7 @@ static void aux_tblinsert_filter(pack_opttbl_t *table,
}
else
{
- error_msg(progname, "cannot insert the filter in this object.\
+ error_msg("cannot insert the filter in this object.\
Maximum capacity exceeded\n");
}
}
@@ -126,7 +124,7 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs )
table->size += n_objs;
table->objs = (pack_info_t*)realloc(table->objs, table->size * sizeof(pack_info_t));
if (table->objs==NULL) {
- error_msg(progname, "not enough memory for options table\n");
+ error_msg("not enough memory for options table\n");
return -1;
}
for (i = table->nelems; i < table->size; i++)
@@ -153,7 +151,7 @@ int options_table_init( pack_opttbl_t **tbl )
if(NULL == (table = (pack_opttbl_t *)malloc(sizeof(pack_opttbl_t))))
{
- error_msg(progname, "not enough memory for options table\n");
+ error_msg("not enough memory for options table\n");
return -1;
}
@@ -161,7 +159,7 @@ int options_table_init( pack_opttbl_t **tbl )
table->nelems = 0;
if(NULL == (table->objs = (pack_info_t*)malloc(table->size * sizeof(pack_info_t))))
{
- error_msg(progname, "not enough memory for options table\n");
+ error_msg("not enough memory for options table\n");
free(table);
return -1;
}
@@ -232,7 +230,7 @@ int options_add_layout( obj_list_t *obj_list,
/* already chunk info inserted for this one; exit */
if (table->objs[i].chunk.rank>0)
{
- error_msg(progname, "chunk information already inserted for <%s>\n",obj_list[j].obj);
+ error_msg("chunk information already inserted for <%s>\n",obj_list[j].obj);
exit(EXIT_FAILURE);
}
/* insert the layout info */
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index 2d8f040..d3a7419 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -21,8 +21,6 @@
#include "h5repack.h"
#include "h5tools_utils.h"
-extern char *progname;
-
/*-------------------------------------------------------------------------
* Function: parse_filter
*
@@ -98,7 +96,7 @@ obj_list_t* parse_filter(const char *str,
obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t));
if (obj_list==NULL)
{
- error_msg(progname, "could not allocate object list\n");
+ error_msg("could not allocate object list\n");
return NULL;
}
*n_objs=n;
@@ -121,7 +119,7 @@ obj_list_t* parse_filter(const char *str,
if (end_obj+1==(int)len)
{
if (obj_list) free(obj_list);
- error_msg(progname, "input Error: Invalid compression type in <%s>\n",str);
+ error_msg("input Error: Invalid compression type in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -159,7 +157,7 @@ obj_list_t* parse_filter(const char *str,
c = str[u];
if (!isdigit(c) && l==-1){
if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter not digit in <%s>\n",str);
+ error_msg("compression parameter not digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (l==-1)
@@ -179,7 +177,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK;
else
{
- error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
+ error_msg("szip mask must be 'NN' or 'EC' \n");
exit(EXIT_FAILURE);
}
@@ -219,7 +217,7 @@ obj_list_t* parse_filter(const char *str,
c = str[u];
if (!isdigit(c) && l==-1){
if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
+ error_msg("compression parameter is not a digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (l==-1)
@@ -239,7 +237,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE;
else
{
- error_msg(progname, "scale type must be 'IN' or 'DS' \n");
+ error_msg("scale type must be 'IN' or 'DS' \n");
exit(EXIT_FAILURE);
}
@@ -263,7 +261,7 @@ obj_list_t* parse_filter(const char *str,
c = str[u];
if (!isdigit(c)){
if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
+ error_msg("compression parameter is not a digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
stype[m]=c;
@@ -309,7 +307,7 @@ obj_list_t* parse_filter(const char *str,
if (no_param)
{ /*no more parameters, GZIP must have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
+ error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -325,7 +323,7 @@ obj_list_t* parse_filter(const char *str,
if (no_param)
{ /*no more parameters, SZIP must have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
+ error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -341,7 +339,7 @@ obj_list_t* parse_filter(const char *str,
if (m>0)
{ /*shuffle does not have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in SHUF <%s>\n",str);
+ error_msg("extra parameter in SHUF <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -356,7 +354,7 @@ obj_list_t* parse_filter(const char *str,
if (m>0)
{ /*shuffle does not have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in FLET <%s>\n",str);
+ error_msg("extra parameter in FLET <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -371,7 +369,7 @@ obj_list_t* parse_filter(const char *str,
if (m>0)
{ /*nbit does not have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in NBIT <%s>\n",str);
+ error_msg("extra parameter in NBIT <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -386,13 +384,13 @@ obj_list_t* parse_filter(const char *str,
if (no_param)
{ /*no more parameters, SOFF must have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
+ error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
else {
if (obj_list) free(obj_list);
- error_msg(progname, "invalid filter type in <%s>\n",str);
+ error_msg("invalid filter type in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -415,7 +413,7 @@ obj_list_t* parse_filter(const char *str,
if (filt->cd_values[0]>9 )
{
if (obj_list) free(obj_list);
- error_msg(progname, "invalid compression parameter in <%s>\n",str);
+ error_msg("invalid compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
break;
@@ -430,19 +428,19 @@ obj_list_t* parse_filter(const char *str,
if ((pixels_per_block%2)==1)
{
if (obj_list) free(obj_list);
- error_msg(progname, "pixels_per_block is not even in <%s>\n",str);
+ error_msg("pixels_per_block is not even in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
{
if (obj_list) free(obj_list);
- error_msg(progname, "pixels_per_block is too large in <%s>\n",str);
+ error_msg("pixels_per_block is too large in <%s>\n",str);
exit(EXIT_FAILURE);
}
if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) )
{
if (obj_list) free(obj_list);
- error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
+ error_msg("szip mask must be 'NN' or 'EC' \n");
exit(EXIT_FAILURE);
}
break;
@@ -519,7 +517,7 @@ obj_list_t* parse_layout(const char *str,
obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t));
if (obj_list==NULL)
{
- error_msg(progname, "could not allocate object list\n");
+ error_msg("could not allocate object list\n");
return NULL;
}
*n_objs=n;
@@ -543,7 +541,7 @@ obj_list_t* parse_layout(const char *str,
if (end_obj+1==(int)len)
{
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, no characters after : in <%s>\n",str);
+ error_msg("in parse layout, no characters after : in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -560,7 +558,7 @@ obj_list_t* parse_layout(const char *str,
else if (strcmp(slayout,"CHUNK")==0)
pack->layout=H5D_CHUNKED;
else {
- error_msg(progname, "in parse layout, not a valid layout in <%s>\n",str);
+ error_msg("in parse layout, not a valid layout in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -584,7 +582,7 @@ obj_list_t* parse_layout(const char *str,
if (j>(int)len)
{
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> Chunk dimensions missing\n",str);
+ error_msg("in parse layout, <%s> Chunk dimensions missing\n",str);
exit(EXIT_FAILURE);
}
@@ -598,7 +596,7 @@ obj_list_t* parse_layout(const char *str,
&& c!='N' && c!='O' && c!='N' && c!='E'
){
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> Not a valid character in <%s>\n",
+ error_msg("in parse layout, <%s> Not a valid character in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
}
@@ -611,7 +609,7 @@ obj_list_t* parse_layout(const char *str,
pack->chunk.chunk_lengths[c_index]=atoi(sdim);
if (pack->chunk.chunk_lengths[c_index]==0) {
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
+ error_msg("in parse layout, <%s> conversion to number in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
}
@@ -629,7 +627,7 @@ obj_list_t* parse_layout(const char *str,
pack->chunk.chunk_lengths[c_index]=atoi(sdim);
if (pack->chunk.chunk_lengths[c_index]==0){
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
+ error_msg("in parse layout, <%s> conversion to number in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
}
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index ac4570b..34c5dd6 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -14,9 +14,9 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
+#include "h5test.h"
#include "h5tools_utils.h"
-extern char *progname;
static int verify_layout(hid_t pid, pack_info_t *obj);
static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter);
@@ -211,26 +211,26 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* Get file creation property list for input file */
if((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto error;
}
/* Get file space management info for input file */
if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) {
- error_msg(progname, "failed to retrieve file space strategy & threshold\n");
+ error_msg("failed to retrieve file space strategy & threshold\n");
goto error;
}
/* Output file is already opened */
/* Get file creation property list for output file */
if((fcpl_out = H5Fget_create_plist(fidout)) < 0) {
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto error;
}
/* Get file space management info for output file */
if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) {
- error_msg(progname, "failed to retrieve file space strategy & threshold\n");
+ error_msg("failed to retrieve file space strategy & threshold\n");
goto error;
}
@@ -243,11 +243,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* as what is set via the strategy option
*/
if(!options->fs_strategy && out_strat != in_strat) {
- error_msg(progname, "file space strategy not set as unexpected\n");
+ error_msg("file space strategy not set as unexpected\n");
goto error;
} else if(options->fs_strategy && out_strat!= options->fs_strategy) {
- error_msg(progname, "file space strategy not set as unexpectec\n");
+ error_msg("file space strategy not set as unexpectec\n");
goto error;
}
@@ -260,11 +260,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* as what is set via the threshold option.
*/
if(!options->fs_threshold && out_thresh != in_thresh) {
- error_msg(progname, "free space threshold not set as unexpected\n");
+ error_msg("free space threshold not set as unexpected\n");
goto error;
} else if(options->fs_threshold && out_thresh != options->fs_threshold) {
- error_msg(progname, "free space threshold not set as unexpectec\n");
+ error_msg("free space threshold not set as unexpectec\n");
goto error;
}
@@ -396,12 +396,12 @@ int h5repack_cmp_pl(const char *fname1,
/* Open the files */
if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
{
- error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR );
+ error_msg("<%s>: %s\n", fname1, H5FOPENERROR );
return -1;
}
if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
{
- error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR );
+ error_msg("<%s>: %s\n", fname2, H5FOPENERROR );
H5Fclose(fid1);
return -1;
}
@@ -450,7 +450,7 @@ int h5repack_cmp_pl(const char *fname1,
if ( crt_order_flag1 != crt_order_flag2 )
{
- error_msg(progname, "property lists for <%s> are different\n",trav->objs[i].name);
+ error_msg("property lists for <%s> are different\n",trav->objs[i].name);
goto error;
}
@@ -478,7 +478,7 @@ int h5repack_cmp_pl(const char *fname1,
if(ret == 0)
{
- error_msg(progname, "property lists for <%s> are different\n",trav->objs[i].name);
+ error_msg("property lists for <%s> are different\n",trav->objs[i].name);
goto error;
}
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 74c901f..a9efe25 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -91,9 +91,8 @@ const char *H5REPACK_FILENAMES[] = {
#define H5REPACK_EXTFILE "h5repack_ext.bin"
-
-const char *progname = "h5repacktst";
-int d_status = EXIT_SUCCESS;
+/* Name of tool */
+#define PROGRAMNAME "h5repacktst"
#define DIM1 40
diff --git a/tools/h5repack/testh5repack_detect_szip.c b/tools/h5repack/testh5repack_detect_szip.c
index b16e0d4..332fcc5 100644
--- a/tools/h5repack/testh5repack_detect_szip.c
+++ b/tools/h5repack/testh5repack_detect_szip.c
@@ -16,8 +16,12 @@
#include <stdio.h>
#include "h5repack.h"
#include "h5tools.h"
+#include "h5test.h"
+/* Name of tool */
+#define PROGRAMNAME "h5repack_detect_szip"
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -40,6 +44,9 @@
int main(void)
{
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
#ifdef H5_HAVE_FILTER_SZIP
if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) {
printf("yes\n");
diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c
index be74d21..fd21266 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
@@ -114,10 +117,6 @@ typedef struct iter_t {
} iter_t;
-const char *progname = "h5stat";
-int d_status = EXIT_SUCCESS;
-
-/* Enable the printing of everything */
static int display_all = TRUE;
/* Enable the printing of selected statistics */
@@ -812,11 +811,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;
@@ -881,15 +880,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("missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end if */
@@ -1541,6 +1540,9 @@ main(int argc, const char *argv[])
struct handler_t *hand;
H5F_info2_t finfo;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable error reporting */
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -1548,7 +1550,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("unable to parse command line arguments \n");
leave(EXIT_FAILURE);
} /* end if */
@@ -1558,7 +1560,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("unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
} /* end if */
@@ -1566,12 +1568,12 @@ main(int argc, const char *argv[])
iter_init(&iter, fid);
if(H5Fget_filesize(fid, &iter.filesize) < 0)
- warn_msg(progname, "Unable to retrieve file size\n");
+ warn_msg("Unable to retrieve file size\n");
assert(iter.filesize != 0);
/* Get storge info for file-level structures */
if(H5Fget_info2(fid, &finfo) < 0)
- warn_msg(progname, "Unable to retrieve file info\n");
+ warn_msg("Unable to retrieve file info\n");
else {
iter.super_size = finfo.super.super_size;
iter.super_ext_size = finfo.super.super_ext_size;
@@ -1583,18 +1585,18 @@ 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("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("Unable to retrieve userblock size\n");
if(H5Pget_file_space(fcpl, &iter.fs_strategy, &iter.fs_threshold) < 0)
- warn_msg(progname, "Unable to retrieve file space information\n");
+ warn_msg("Unable to retrieve file space information\n");
assert(iter.fs_strategy != 0 && iter.fs_strategy < H5F_FILE_SPACE_NTYPES);
/* get information for free-space sections */
if(freespace_stats(fid, &iter) < 0)
- warn_msg(progname, "Unable to retrieve freespace info\n");
+ warn_msg("Unable to retrieve freespace info\n");
/* Walk the objects or all file */
if(display_object) {
@@ -1603,7 +1605,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("Unable to traverse object \"%s\"\n", hand[u].obj);
else
print_statistics(hand[u].obj, &iter);
u++;
@@ -1611,7 +1613,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("Unable to traverse objects/links in file \"%s\"\n", fname);
else
print_statistics("/", &iter);
} /* end else */
@@ -1619,7 +1621,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("unable to close file \"%s\"\n", fname);
leave(EXIT_FAILURE);
}
diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h
index 6718d9a..ede6ea0 100644
--- a/tools/lib/h5diff.h
+++ b/tools/lib/h5diff.h
@@ -55,15 +55,15 @@ typedef struct {
extern "C" {
#endif
-hsize_t h5diff(const char *fname1,
+H5TOOLS_DLL hsize_t h5diff(const char *fname1,
const char *fname2,
const char *objname1,
const char *objname2,
diff_opt_t *options);
#ifdef H5_HAVE_PARALLEL
-void phdiff_dismiss_workers(void);
-void print_manager_output(void);
+H5TOOLS_DLL void phdiff_dismiss_workers(void);
+H5TOOLS_DLL void print_manager_output(void);
#endif
#ifdef __cplusplus
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index e997d03..5d4ea87 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -42,6 +42,8 @@ FILE *rawdatastream; /* should initialize to stdout but gcc moans about it
int bin_output; /* binary output */
int bin_form; /* binary form */
int region_output; /* region output */
+static int h5tools_d_status = 0;
+static const char *h5tools_progname = "h5tools";
static h5tool_format_t h5tools_dataformat = {
0, /*raw */
@@ -283,6 +285,34 @@ enum {
/*-------------------------------------------------------------------------
* Audience: Public
* Chapter: H5Tools Library
+ * Purpose: Initialize the name and operation status of the H5 Tools library
+ * Description:
+ * These are utility functions to set/get the program name and operation status.
+ *-------------------------------------------------------------------------
+ */
+void h5tools_setprogname(const char *Progname)
+{
+ h5tools_progname = Progname;
+}
+
+void h5tools_setstatus(int D_status)
+{
+ h5tools_d_status = D_status;
+}
+
+const char*h5tools_getprogname()
+{
+ return h5tools_progname;
+}
+
+int h5tools_getstatus()
+{
+ return h5tools_d_status;
+}
+
+/*-------------------------------------------------------------------------
+ * Audience: Public
+ * Chapter: H5Tools Library
* Purpose: Initialize the H5 Tools library
* Description:
* This should be called before any other h5tools function is called.
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 7d207ba..cb01580 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -521,10 +521,14 @@ struct subset_t {
#include "h5tools_str.h"
-extern FILE *rawdatastream; /* output stream for raw data */
-extern int bin_output; /* binary output */
-extern int bin_form; /* binary form */
-extern int region_output; /* region output */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+H5TOOLS_DLLVAR FILE *rawdatastream; /* output stream for raw data */
+H5TOOLS_DLLVAR int bin_output; /* binary output */
+H5TOOLS_DLLVAR int bin_form; /* binary form */
+H5TOOLS_DLLVAR int region_output; /* region output */
/* Strings for output */
#define H5_TOOLS_GROUP "GROUP"
@@ -532,26 +536,30 @@ extern int region_output; /* region output */
#define H5_TOOLS_DATATYPE "DATATYPE"
/* Definitions of useful routines */
-extern void h5tools_init(void);
-extern void h5tools_close(void);
-extern hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl,
+H5TOOLS_DLL const char *h5tools_getprogname(void);
+H5TOOLS_DLL void h5tools_setprogname(const char*progname);
+H5TOOLS_DLL int h5tools_getstatus(void);
+H5TOOLS_DLL void h5tools_setstatus(int d_status);
+H5TOOLS_DLL void h5tools_init(void);
+H5TOOLS_DLL void h5tools_close(void);
+H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl,
const char *driver, char *drivername, size_t drivername_len);
-extern int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
+H5TOOLS_DLL int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, hid_t dset,
hid_t p_typ, struct subset_t *sset, int indentlevel);
-extern int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id,
+H5TOOLS_DLL int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id,
hid_t type, hid_t space, void *mem, int indentlevel);
-extern hid_t h5tools_get_native_type(hid_t type);
-extern hid_t h5tools_get_little_endian_type(hid_t type);
-extern hid_t h5tools_get_big_endian_type(hid_t type);
+H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type);
+H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type);
+H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type);
-extern void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
+H5TOOLS_DLL void h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t container,
h5tools_context_t *ctx/*in,out*/, unsigned flags,
hsize_t nelmts, hid_t type, void *_mem);
-extern int h5tools_canreadf(const char* name,
+H5TOOLS_DLL int h5tools_canreadf(const char* name,
hid_t dcpl_id);
-extern int h5tools_can_encode(H5Z_filter_t filtn);
+H5TOOLS_DLL int h5tools_can_encode(H5Z_filter_t filtn);
void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims);
/*
@@ -564,5 +572,10 @@ int h5tools_print_datatype(h5tools_str_t *buffer/*in,out*/,
const h5tool_format_t *info, h5tools_context_t *ctx/*in,out*/,
hid_t type);
int h5tools_print_enum(h5tools_str_t *buffer/*in,out*/, hid_t type);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* H5TOOLS_H__ */
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index a7c0d3c..207218e 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -22,9 +22,9 @@
#include "H5Epublic.h"
/* tools-HDF5 Error variables */
-extern hid_t H5tools_ERR_CLS_g;
-extern hid_t H5E_tools_g;
-extern hid_t H5E_tools_min_id_g;
+H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_g;
+H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g;
/* Use FUNC to safely handle variations of C99 __func__ keyword handling */
#ifdef H5_HAVE_C99_FUNC
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index 03e6efd..07d2a57 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -45,9 +45,6 @@ typedef struct {
static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */
static hid_t thefile = (-1);
-extern char *progname;
-extern int d_status;
-
static int ref_path_table_put(const char *, haddr_t objno);
/*-------------------------------------------------------------------------
@@ -122,8 +119,8 @@ init_ref_path_table(void)
/* Iterate over objects in this file */
if(h5trav_visit(thefile, "/", TRUE, TRUE, init_ref_path_cb, NULL, NULL) < 0) {
- error_msg(progname, "unable to construct reference path table\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to construct reference path table\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
return(0);
diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h
index 567ca4b..7ddb91a 100644
--- a/tools/lib/h5tools_ref.h
+++ b/tools/lib/h5tools_ref.h
@@ -22,13 +22,13 @@
extern "C" {
#endif
-herr_t fill_ref_path_table(hid_t fid);
-const char *lookup_ref_path(haddr_t ref);
-int get_next_xid(void);
-haddr_t get_fake_xid(void);
-haddr_t ref_path_table_lookup(const char *);
-haddr_t ref_path_table_gen_fake(const char *);
-int term_ref_path_table(void);
+H5TOOLS_DLL herr_t fill_ref_path_table(hid_t fid);
+H5TOOLS_DLL const char *lookup_ref_path(haddr_t ref);
+H5TOOLS_DLL int get_next_xid(void);
+H5TOOLS_DLL haddr_t get_fake_xid(void);
+H5TOOLS_DLL haddr_t ref_path_table_lookup(const char *);
+H5TOOLS_DLL haddr_t ref_path_table_gen_fake(const char *);
+H5TOOLS_DLL int term_ref_path_table(void);
#ifdef __cplusplus
}
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index a51a286..757d4d7 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -64,13 +64,13 @@ static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t
*-------------------------------------------------------------------------
*/
void
-error_msg(const char *progname, const char *fmt, ...)
+error_msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
HDfflush(stdout);
- HDfprintf(stderr, "%s error: ", progname);
+ HDfprintf(stderr, "%s error: ", h5tools_getprogname());
HDvfprintf(stderr, fmt, ap);
va_end(ap);
@@ -93,13 +93,13 @@ error_msg(const char *progname, const char *fmt, ...)
*-------------------------------------------------------------------------
*/
void
-warn_msg(const char *progname, const char *fmt, ...)
+warn_msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
HDfflush(stdout);
- HDfprintf(stderr, "%s warning: ", progname);
+ HDfprintf(stderr, "%s warning: ", h5tools_getprogname());
HDvfprintf(stderr, fmt, ap);
va_end(ap);
}
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index dcd8f2b..3720afd 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -24,12 +24,16 @@
#include "hdf5.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* begin get_option section
*/
-extern int opt_err; /* getoption prints errors if this is on */
-extern int opt_ind; /* token pointer */
-extern const char *opt_arg; /* flag argument (or value) */
+H5TOOLS_DLLVAR int opt_err; /* getoption prints errors if this is on */
+H5TOOLS_DLLVAR int opt_ind; /* token pointer */
+H5TOOLS_DLLVAR const char *opt_arg; /* flag argument (or value) */
enum {
no_arg = 0, /* doesn't take an argument */
@@ -72,7 +76,7 @@ typedef struct long_options {
* this gets returned from get_option */
} long_options;
-extern int get_option(int argc, const char **argv, const char *opt,
+H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt,
const struct long_options *l_opt);
/*
* end get_option section
@@ -101,25 +105,24 @@ typedef struct find_objs_t {
table_t *dset_table;
} find_objs_t;
-extern int nCols; /*max number of columns for outputting */
+H5TOOLS_DLLVAR int nCols; /*max number of columns for outputting */
/* Definitions of useful routines */
-extern void indentation(int);
-extern void print_version(const char *progname);
-extern void error_msg(const char *progname, const char *fmt, ...);
-extern void warn_msg(const char *progname, const char *fmt, ...);
-extern void free_table(table_t *table);
+H5TOOLS_DLL void indentation(int);
+H5TOOLS_DLL void print_version(const char *progname);
+H5TOOLS_DLL void error_msg(const char *fmt, ...);
+H5TOOLS_DLL void warn_msg(const char *fmt, ...);
+H5TOOLS_DLL void free_table(table_t *table);
#ifdef H5DUMP_DEBUG
-extern void dump_tables(find_objs_t *info)
+H5TOOLS_DLL void dump_tables(find_objs_t *info)
#endif /* H5DUMP_DEBUG */
-extern herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
+H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
table_t **dset_table, table_t **type_table);
-extern obj_t *search_obj(table_t *temp, haddr_t objno);
+H5TOOLS_DLL obj_t *search_obj(table_t *temp, haddr_t objno);
#ifndef H5_HAVE_TMPFILE
-extern FILE * tmpfile(void);
+H5TOOLS_DLL FILE * tmpfile(void);
#endif
-
/*************************************************************
*
* candidate functions to be public
@@ -148,6 +151,10 @@ typedef struct {
/* Definitions of routines */
-extern int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info);
+H5TOOLS_DLL int H5tools_get_link_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* H5TOOLS_UTILS_H__ */
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index 5c07331..bb31461 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -110,7 +110,7 @@ extern "C" {
* "h5trav general" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start,
+H5TOOLS_DLL int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start,
hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk,
void *udata);
@@ -118,22 +118,22 @@ int h5trav_visit(hid_t file_id, const char *grp_name, hbool_t visit_start,
* "h5trav info" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_getinfo(hid_t file_id, trav_info_t *info);
-ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
+H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info);
+H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
/*-------------------------------------------------------------------------
* "h5trav table" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_gettable(hid_t fid, trav_table_t *travt);
-int h5trav_getindext(const char *obj, const trav_table_t *travt);
+H5TOOLS_DLL int h5trav_gettable(hid_t fid, trav_table_t *travt);
+H5TOOLS_DLL int h5trav_getindext(const char *obj, const trav_table_t *travt);
/*-------------------------------------------------------------------------
* "h5trav print" public functions
*-------------------------------------------------------------------------
*/
-int h5trav_print(hid_t fid);
+H5TOOLS_DLL int h5trav_print(hid_t fid);
#ifdef __cplusplus
}
@@ -144,20 +144,20 @@ int h5trav_print(hid_t fid);
*-------------------------------------------------------------------------
*/
-void trav_info_init(trav_info_t **info);
+H5TOOLS_DLL void trav_info_init(trav_info_t **info);
-void trav_info_free(trav_info_t *info);
+H5TOOLS_DLL void trav_info_free(trav_info_t *info);
/*-------------------------------------------------------------------------
* table private functions
*-------------------------------------------------------------------------
*/
-void trav_table_init(trav_table_t **table);
+H5TOOLS_DLL void trav_table_init(trav_table_t **table);
-void trav_table_free(trav_table_t *table);
+H5TOOLS_DLL void trav_table_free(trav_table_t *table);
-void trav_table_addflags(unsigned *flags,
+H5TOOLS_DLL void trav_table_addflags(unsigned *flags,
char *objname,
h5trav_type_t type,
trav_table_t *table);
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c
index a6fdc56..09f23ef 100644
--- a/tools/misc/h5mkgrp.c
+++ b/tools/misc/h5mkgrp.c
@@ -21,7 +21,7 @@
#include <stdlib.h>
/* Name of tool */
-const char *progname = "h5mkgrp";
+#define PROGRAMNAME "h5mkgrp"
/* Exit status for tools library routines */
int d_status = EXIT_SUCCESS;
@@ -141,7 +141,7 @@ parse_command_line(int argc, const char *argv[], param_t *params)
/* Display version */
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
/* Bad command line argument */
@@ -153,7 +153,7 @@ parse_command_line(int argc, const char *argv[], param_t *params)
/* Check for file name to be processed */
if(argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
+ error_msg("missing file name\n");
usage();
leave(EXIT_FAILURE);
} /* end if */
@@ -164,7 +164,7 @@ parse_command_line(int argc, const char *argv[], param_t *params)
/* Check for group(s) to be created */
if(argc <= opt_ind) {
- error_msg(progname, "missing group name(s)\n");
+ error_msg("missing group name(s)\n");
usage();
leave(EXIT_FAILURE);
} /* end if */
@@ -212,6 +212,9 @@ main(int argc, const char *argv[])
hid_t lcpl_id; /* Link creation property list ID */
size_t curr_group; /* Current group to create */
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable the HDF5 library's error reporting */
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -221,13 +224,13 @@ main(int argc, const char *argv[])
/* Parse command line */
HDmemset(&params, 0, sizeof(params));
if(parse_command_line(argc, argv, &params) < 0) {
- error_msg(progname, "unable to parse command line arguments\n");
+ error_msg("unable to parse command line arguments\n");
leave(EXIT_FAILURE);
} /* end if */
/* Create file access property list */
if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
- error_msg(progname, "Could not create file access property list\n");
+ error_msg("Could not create file access property list\n");
leave(EXIT_FAILURE);
} /* end if */
@@ -235,13 +238,13 @@ main(int argc, const char *argv[])
if(params.latest) {
/* Set the "use the latest version of the format" bounds */
if(H5Pset_libver_bounds(fapl_id, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
- error_msg(progname, "Could not set property for using latest version of the format\n");
+ error_msg("Could not set property for using latest version of the format\n");
leave(EXIT_FAILURE);
} /* end if */
/* Display some output if requested */
if(params.verbose)
- printf("%s: Creating groups with latest version of the format\n", progname);
+ printf("%s: Creating groups with latest version of the format\n", h5tools_getprogname());
} /* end if */
/* Attempt to open an existing HDF5 file first */
@@ -254,13 +257,13 @@ main(int argc, const char *argv[])
/* Test for error in opening file */
if(fid < 0) {
- error_msg(progname, "Could not open output file '%s'\n", params.fname);
+ error_msg("Could not open output file '%s'\n", params.fname);
leave(EXIT_FAILURE);
} /* end if */
/* Create link creation property list */
if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) {
- error_msg(progname, "Could not create link creation property list\n");
+ error_msg("Could not create link creation property list\n");
leave(EXIT_FAILURE);
} /* end if */
@@ -268,13 +271,13 @@ main(int argc, const char *argv[])
if(params.parents) {
/* Set the intermediate group creation property */
if(H5Pset_create_intermediate_group(lcpl_id, TRUE) < 0) {
- error_msg(progname, "Could not set property for creating parent groups\n");
+ error_msg("Could not set property for creating parent groups\n");
leave(EXIT_FAILURE);
} /* end if */
/* Display some output if requested */
if(params.verbose)
- printf("%s: Creating parent groups\n", progname);
+ printf("%s: Creating parent groups\n", h5tools_getprogname());
} /* end if */
/* Loop over creating requested groups */
@@ -283,36 +286,36 @@ main(int argc, const char *argv[])
/* Attempt to create a group */
if((gid = H5Gcreate2(fid, params.groups[curr_group], lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
- error_msg(progname, "Could not create group '%s'\n", params.groups[curr_group]);
+ error_msg("Could not create group '%s'\n", params.groups[curr_group]);
leave(EXIT_FAILURE);
} /* end if */
/* Close the group */
if(H5Gclose(gid) < 0) {
- error_msg(progname, "Could not close group '%s'??\n", params.groups[curr_group]);
+ error_msg("Could not close group '%s'??\n", params.groups[curr_group]);
leave(EXIT_FAILURE);
} /* end if */
/* Display some output if requested */
if(params.verbose)
- printf("%s: created group '%s'\n", progname, params.groups[curr_group]);
+ printf("%s: created group '%s'\n", h5tools_getprogname(), params.groups[curr_group]);
} /* end for */
/* Close link creation property list */
if(H5Pclose(lcpl_id) < 0) {
- error_msg(progname, "Could not close link creation property list\n");
+ error_msg("Could not close link creation property list\n");
leave(EXIT_FAILURE);
} /* end if */
/* Close file */
if(H5Fclose(fid) < 0) {
- error_msg(progname, "Could not close output file '%s'??\n", params.fname);
+ error_msg("Could not close output file '%s'??\n", params.fname);
leave(EXIT_FAILURE);
} /* end if */
/* Close file access property list */
if(H5Pclose(fapl_id) < 0) {
- error_msg(progname, "Could not close file access property list\n");
+ error_msg("Could not close file access property list\n");
leave(EXIT_FAILURE);
} /* end if */