summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perform/perf_meta.c3
-rw-r--r--perform/zip_perf.c24
-rw-r--r--test/h5test.h9
-rw-r--r--tools/h5copy/h5copy.c30
-rw-r--r--tools/h5copy/h5copygentest.c20
-rw-r--r--tools/h5diff/h5diff_common.c10
-rw-r--r--tools/h5diff/h5diff_main.c8
-rw-r--r--tools/h5diff/h5diffgentest.c8
-rw-r--r--tools/h5diff/ph5diff_main.c9
-rw-r--r--tools/h5dump/h5dump.c336
-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.c49
-rw-r--r--tools/h5repack/h5repack_main.c39
-rw-r--r--tools/h5repack/h5repack_opttable.c12
-rw-r--r--tools/h5repack/h5repack_parse.c52
-rw-r--r--tools/h5repack/h5repack_verify.c9
-rw-r--r--tools/h5repack/h5repacktst.c5
-rw-r--r--tools/h5repack/testh5repack_detect_szip.c5
-rw-r--r--tools/h5stat/h5stat.c58
-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.h39
-rw-r--r--tools/lib/h5trav.h22
-rw-r--r--tools/lib/ph5diff.h10
-rw-r--r--tools/misc/h5mkgrp.c39
-rwxr-xr-xwindows/src/H5pubconf.h3
37 files changed, 604 insertions, 501 deletions
diff --git a/perform/perf_meta.c b/perform/perf_meta.c
index 279c8de..8c3b06f 100644
--- a/perform/perf_meta.c
+++ b/perform/perf_meta.c
@@ -21,7 +21,6 @@
*/
#include "h5test.h"
-#include <sys/time.h>
#ifdef H5_HAVE_PARALLEL
#define MAINPROCESS (!mpi_rank) /* define process 0 as main process */
@@ -683,7 +682,7 @@ double retrieve_time(void)
if(facc_type == FACC_DEFAULT) {
#endif /*H5_HAVE_PARALLEL*/
struct timeval t;
- gettimeofday(&t, NULL);
+ HDgettimeofday(&t, NULL);
return ((double)t.tv_sec + (double)t.tv_usec / 1000000);
#ifdef H5_HAVE_PARALLEL
} else {
diff --git a/perform/zip_perf.c b/perform/zip_perf.c
index d1d36b4..7d96405 100644
--- a/perform/zip_perf.c
+++ b/perform/zip_perf.c
@@ -28,14 +28,15 @@
#include <errno.h>
#include <fcntl.h>
#include <math.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
+
+#ifdef H5_HAVE_UNISTD_H
+# include <unistd.h>
+#endif
/* our header files */
-#include "hdf5.h"
-#include "H5private.h"
+#include "h5test.h"
#include "h5tools_utils.h"
#ifdef H5_HAVE_FILTER_DEFLATE
@@ -86,6 +87,9 @@
#define FALSE (!TRUE)
#endif /* FALSE */
+#ifndef S_IRWXU
+#define S_IRWXU (_S_IREAD|_S_IWRITE)
+#endif
/* internal variables */
static const char *prog;
@@ -214,9 +218,9 @@ write_file(Bytef *source, uLongf sourceLen)
if (!dest)
error("out of memory");
- gettimeofday(&timer_start, NULL);
+ HDgettimeofday(&timer_start, NULL);
compress_buffer(dest, &destLen, source, sourceLen);
- gettimeofday(&timer_stop, NULL);
+ HDgettimeofday(&timer_stop, NULL);
compression_time += ((double)timer_stop.tv_sec +
((double)timer_stop.tv_usec) / MICROSECOND) -
@@ -508,7 +512,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size,
printf("\n");
/* do uncompressed data write */
- gettimeofday(&timer_start, NULL);
+ HDgettimeofday(&timer_start, NULL);
output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU);
if (output == -1)
@@ -534,7 +538,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size,
}
close(output);
- gettimeofday(&timer_stop, NULL);
+ HDgettimeofday(&timer_stop, NULL);
total_time = ((double)timer_stop.tv_sec +
((double)timer_stop.tv_usec) / MICROSECOND) -
@@ -554,13 +558,13 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size,
error(strerror(errno));
report_once_flag = 1;
- gettimeofday(&timer_start, NULL);
+ HDgettimeofday(&timer_start, NULL);
for (total_len = 0; total_len < file_size; total_len += src_len)
write_file(src, src_len);
close(output);
- gettimeofday(&timer_stop, NULL);
+ HDgettimeofday(&timer_stop, NULL);
total_time = ((double)timer_stop.tv_sec +
((double)timer_stop.tv_usec) / MICROSECOND) -
diff --git a/test/h5test.h b/test/h5test.h
index f984751..ff065bc 100644
--- a/test/h5test.h
+++ b/test/h5test.h
@@ -30,6 +30,15 @@
# include <stdarg.h>
#endif
+#if defined(H5_TIME_WITH_SYS_TIME)
+# include <sys/time.h>
+# include <time.h>
+#elif defined(H5_HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#else
+# include <time.h>
+#endif
+
/*
* Predefined test verbosity levels.
*
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c
index 0ea8e16..20b28e1 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(h5tools_getprogname(), "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(h5tools_getprogname(), "Input file name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (fname_dst==NULL)
{
- error_msg(progname, "Output file name missing\n");
+ error_msg(h5tools_getprogname(), "Output file name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (oname_src==NULL)
{
- error_msg(progname, "Source object name missing\n");
+ error_msg(h5tools_getprogname(), "Source object name missing\n");
usage();
leave(EXIT_FAILURE);
}
if (oname_dst==NULL)
{
- error_msg(progname, "Destination object name missing\n");
+ error_msg(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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..f359a9b 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"
@@ -225,7 +228,7 @@ static void gent_compressed(hid_t loc_id)
/*-------------------------------------------------------------------------
* Function: gent_named_vl
*
- * Purpose: Generate a variable lenght named datatype for a dataset in
+ * Purpose: Generate a variable lenght named datatype for a dataset in
LOC_ID
*
*-------------------------------------------------------------------------
@@ -640,12 +643,12 @@ out:
/*-------------------------------------------------------------------------
* Function: Test_Obj_Copy
*
- * Purpose: Testing with various objects
+ * Purpose: Testing with various objects
*
*------------------------------------------------------------------------*/
static void Test_Obj_Copy()
{
- hid_t fid=0;
+ hid_t fid=0;
/* Create source file */
fid = H5Fcreate(HDF_FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -678,14 +681,14 @@ static void Test_Ref_Copy()
{
hid_t fid=0;
herr_t status;
-
+
fid = H5Fcreate (HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid < 0)
{
fprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_FILE2);
goto out;
}
-
+
/* add object reference */
status = gen_obj_ref(fid);
if (status < 0)
@@ -845,7 +848,7 @@ static void Test_Extlink_Copy()
hid_t fid1=0;
hid_t fid2=0;
herr_t status;
-
+
fid1 = H5Fcreate (HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (fid1 < 0)
{
@@ -859,7 +862,7 @@ static void Test_Extlink_Copy()
fprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_TRG_FILE);
goto out;
}
-
+
/* add links to source external link file */
status = gen_extlink_src(fid1);
if (status < 0)
@@ -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..f121d65 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;
@@ -103,7 +99,7 @@ void parse_command_line(int argc,
options->m_report = 1;
break;
case 'l':
- options->follow_links = 1;
+ options->follow_links = 1;
break;
case 'x':
options->no_dangle_links = 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(h5tools_getprogname(), "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..3cf434b 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);
@@ -923,7 +923,7 @@ int test_datasets(const char *file,
/*-------------------------------------------------------------------------
*
-* Purpose: Create test files to compare links, one has longer name than
+* Purpose: Create test files to compare links, one has longer name than
* the other and short name is subset of long name.
*
* Programmer: Jonathan Kim (Feb 17, 2010)
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 66bef67..49bcb8f 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;
@@ -103,13 +101,13 @@ static H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order
static H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
#ifdef H5_HAVE_H5DUMP_PACKED_BITS
+#define PACKED_BITS_LOOP_MAX 8
/* mask list for packed bits */
-static unsigned int packed_mask[8]; /* packed bits are restricted to 1 byte */
+static unsigned int packed_mask[PACKED_BITS_LOOP_MAX]; /* packed bits are restricted to 1 byte */
/* packed bits display parameters */
-static int packed_offset[8];
-static int packed_length[8];
-#define PACKED_BITS_LOOP_MAX 8
+static int packed_offset[PACKED_BITS_LOOP_MAX];
+static int packed_length[PACKED_BITS_LOOP_MAX];
#endif
/**
@@ -850,7 +848,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);
@@ -912,8 +910,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(h5tools_getprogname(), "unknown committed type.\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
switch(H5Tget_class(type)) {
@@ -1152,7 +1150,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);
@@ -1182,7 +1180,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;
@@ -1289,7 +1287,7 @@ print_datatype(hid_t type,unsigned in_group)
default:
printf("unknown datatype");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
break;
}
} /* end else */
@@ -1432,11 +1430,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(h5tools_getprogname(), "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;
@@ -1508,9 +1506,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(h5tools_getprogname(), "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 */
@@ -1535,14 +1533,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(h5tools_getprogname(), "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 */
@@ -1590,8 +1588,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(h5tools_getprogname(), "unable to get object information for \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
goto done;
} /* end if */
@@ -1601,8 +1599,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(h5tools_getprogname(), "unable to dump group \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else
@@ -1640,13 +1638,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;
@@ -1709,16 +1707,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(h5tools_getprogname(), "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(h5tools_getprogname(), "unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
dump_function_table->dump_named_datatype_function(obj, name);
@@ -1727,8 +1725,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(h5tools_getprogname(), "unknown object \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
} /* end if */
@@ -1748,8 +1746,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(h5tools_getprogname(), "unable to get link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
/* print the value of a soft link */
@@ -1839,8 +1837,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(h5tools_getprogname(), "unable to get external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
@@ -1848,8 +1846,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(h5tools_getprogname(), "unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
@@ -1981,20 +1979,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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "error in closing creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -2013,9 +2011,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(h5tools_getprogname(), "internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
else if (found_obj->displayed) {
@@ -2038,14 +2036,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2087,27 +2085,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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -2149,9 +2147,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(h5tools_getprogname(), "internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
else if (found_obj->displayed) {
indentation(indent);
@@ -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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2195,14 +2193,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2253,15 +2251,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
indentation(indent);
@@ -2330,14 +2328,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2648,8 +2646,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(h5tools_getprogname(), "unable to print data\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
indentation(indent);
@@ -3704,10 +3702,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(h5tools_getprogname(), "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 */
@@ -3774,8 +3772,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(h5tools_getprogname(), "wrong subset selection; blocks overlap\n");
+ h5tools_setstatus(EXIT_FAILURE);
return;
}
@@ -3809,13 +3807,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);
}
/*-------------------------------------------------------------------------
@@ -3851,9 +3849,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(h5tools_getprogname(), "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
@@ -3871,7 +3869,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() */
@@ -3895,11 +3893,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(h5tools_getprogname(), "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(h5tools_getprogname(), "\"%s\" is a hard link\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
} else {
char *buf = HDmalloc(linfo.u.val_size);
@@ -3911,9 +3909,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(h5tools_getprogname(), "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);
@@ -3937,12 +3935,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(h5tools_getprogname(), "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(h5tools_getprogname(), "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);
@@ -4018,10 +4016,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(h5tools_getprogname(), "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
@@ -4038,7 +4036,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);
}
}
@@ -4070,7 +4068,7 @@ parse_command_line(int argc, const char *argv[])
/* no arguments */
if (argc == 1) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
@@ -4120,7 +4118,7 @@ parse_start:
display_char = TRUE;
break;
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
case 'w':
@@ -4196,13 +4194,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);
}
}
@@ -4216,7 +4214,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);
}
}
@@ -4224,7 +4222,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);
}
@@ -4235,7 +4233,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;
@@ -4243,7 +4241,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;
@@ -4251,7 +4249,7 @@ parse_start:
#ifdef H5_HAVE_H5DUMP_PACKED_BITS
case 'M':
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);
@@ -4294,7 +4292,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) {
@@ -4313,7 +4311,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);
@@ -4361,11 +4359,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);
}
}
@@ -4373,8 +4371,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(h5tools_getprogname(), "missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
return hand;
@@ -4468,6 +4466,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;
@@ -4481,43 +4481,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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
fname = HDstrdup(argv[opt_ind]);
@@ -4525,7 +4525,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(h5tools_getprogname(), "unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
}
@@ -4551,7 +4551,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(h5tools_getprogname(), "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
leave(EXIT_FAILURE);
}
}
@@ -4560,15 +4560,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(h5tools_getprogname(), "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(h5tools_getprogname(), "internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
group_table = table_list.tables[0].group_table;
@@ -4630,8 +4630,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(h5tools_getprogname(), "unable to open root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
else
{
@@ -4642,8 +4642,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(h5tools_getprogname(), "unable to close root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -4652,8 +4652,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(h5tools_getprogname(), "internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
} /* end if */
@@ -4673,7 +4673,7 @@ done:
table_list_free();
if (H5Fclose(fid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
free_handler(hand, argc);
@@ -4684,7 +4684,7 @@ done:
H5Eset_auto2(H5E_DEFAULT, func, edata);
- leave(d_status);
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
@@ -5097,7 +5097,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 {
@@ -5401,7 +5401,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 */
@@ -5783,7 +5783,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;
}
}
@@ -5858,9 +5858,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(h5tools_getprogname(), "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
@@ -5939,27 +5939,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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(HDstrcmp(name, "/") == 0) {
@@ -5991,9 +5991,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(h5tools_getprogname(), "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);
@@ -6058,14 +6058,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -6130,14 +6130,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -6796,14 +6796,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(h5tools_getprogname(), "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(h5tools_getprogname(), "error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -7236,7 +7236,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;
@@ -7251,7 +7251,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 c3fe11d..2aff97f 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..7468db2 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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "missing size\n");
+ usage (h5tools_getprogname());
exit (EXIT_FAILURE);
}
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);
}
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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "can't open file %s\n", filename);
exit (EXIT_FAILURE);
}
diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c
index cceed75..6fdd744 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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "Can't stat file \n");
exit (EXIT_FAILURE);
}
diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c
index 5e4d864..a69fd45 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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "\"%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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "??\"%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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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..450759f 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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 (h5tools_getprogname(), "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 0256650..ddca593 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
@@ -157,7 +153,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(h5tools_getprogname(), "maximum number of filters exceeded for <%s>\n", str);
free(obj_list);
return -1;
}
@@ -195,7 +191,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(h5tools_getprogname(), "invalid layout input: 'all' option \
is present with other objects <%s>\n",str);
return -1;
}
@@ -614,7 +610,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(h5tools_getprogname(), "invalid layout\n");
return -1;
default:
strcpy(slayout,"invalid layout\n");
@@ -655,7 +651,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(h5tools_getprogname(), "invalid chunking input: 'all' option\
is present with other objects\n");
return -1;
}
@@ -717,7 +713,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(h5tools_getprogname(), "invalid compression input: 'all' option\
is present with other objects\n");
return -1;
}
@@ -729,24 +725,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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "invalid shared message size\n");
return -1;
}
}
@@ -768,7 +764,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(h5tools_getprogname(), "file name missing for user block\n",
options->ublock_filename);
return -1;
}
@@ -781,7 +777,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(h5tools_getprogname(), "alignment for H5Pset_alignment missing\n");
return -1;
}
@@ -853,7 +849,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(h5tools_getprogname(), "%s Could not find <%s> in file <%s>. Exiting...\n",
(options->verbose?"\n":""),name,fname);
goto out;
}
@@ -975,7 +971,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(h5tools_getprogname(), "input error in filter type\n");
exit(EXIT_FAILURE);
}
}
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 4376390..b4c191c 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(h5tools_getprogname(), "<%s>: %s\n", fnamein, H5FOPENERROR );
goto out;
}
@@ -100,19 +99,19 @@ 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(h5tools_getprogname(), "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(h5tools_getprogname(), "failed to retrieve userblock size\n");
goto out;
}
if(H5Pclose(fcpl_in) < 0)
{
- error_msg(progname, "failed to close property list\n");
+ error_msg(h5tools_getprogname(), "failed to close property list\n");
goto out;
}
}
@@ -123,7 +122,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(h5tools_getprogname(), "fail to create a file creation property list\n");
goto out;
}
@@ -131,7 +130,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(h5tools_getprogname(), "failed to set non-default userblock size\n");
goto out;
}
}
@@ -144,7 +143,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(h5tools_getprogname(), "fail to adjust group creation parameters for root group\n");
goto out;
}
@@ -186,7 +185,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(h5tools_getprogname(), "fail to set the number of shared object header message indexes\n");
goto out;
}
@@ -194,7 +193,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(h5tools_getprogname(), "fail to configure the specified shared object header message index\n");
goto out;
} /* end if */
} /* end for */
@@ -203,13 +202,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(h5tools_getprogname(), "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(h5tools_getprogname(), "Could not set property for using latest version of the format\n");
goto out;
} /* end if */
} /* end if */
@@ -236,7 +235,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(h5tools_getprogname(), "failed to set userblock size\n");
goto out;
}
@@ -248,14 +247,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(h5tools_getprogname(), "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(h5tools_getprogname(), "failed to set userblock size\n");
goto out;
}
@@ -280,7 +279,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(h5tools_getprogname(), "failed to set alignment\n");
goto out;
}
@@ -292,13 +291,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(h5tools_getprogname(), "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(h5tools_getprogname(), "failed to set alignment\n");
goto out;
}
@@ -319,7 +318,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(h5tools_getprogname(), "<%s>: Could not create file\n", fnameout );
goto out;
}
@@ -332,7 +331,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(h5tools_getprogname(), "Could not copy user block. Exiting...\n");
goto out;
}
@@ -356,7 +355,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(h5tools_getprogname(), "<%s>: Could not copy data to: %s\n", fnamein, fnameout);
goto out;
} /* end if */
@@ -398,7 +397,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(h5tools_getprogname(), "Could not copy user block. Exiting...\n");
goto out;
}
@@ -1362,19 +1361,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(h5tools_getprogname(), "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(h5tools_getprogname(), "failed to retrieve userblock size\n");
goto done;
}
if(H5Pclose(fcpl) < 0)
{
- error_msg(progname, "failed to close property list\n");
+ error_msg(h5tools_getprogname(), "failed to close property list\n");
goto done;
}
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index f52aa5a..aaabeac 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;
@@ -105,6 +105,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);
@@ -121,8 +124,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(h5tools_getprogname(), "file names cannot be the same\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
@@ -130,8 +133,8 @@ int main(int argc, const char **argv)
else
{
- error_msg(progname, "file names missing\n");
- usage(progname);
+ error_msg(h5tools_getprogname(), "file names missing\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -304,10 +307,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;
@@ -317,7 +320,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(h5tools_getprogname(), "in parsing filter\n");
exit(EXIT_FAILURE);
}
break;
@@ -326,7 +329,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(h5tools_getprogname(), "in parsing layout\n");
exit(EXIT_FAILURE);
}
break;
@@ -337,7 +340,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(h5tools_getprogname(), "invalid minimum compress size <%s>\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -430,7 +433,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(h5tools_getprogname(), "invalid alignment size\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -445,8 +448,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(h5tools_getprogname(), "missing file names\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -489,7 +492,7 @@ void read_info(const char *filename,
if ((fp = fopen(data_file, "r")) == (FILE *)NULL) {
- error_msg(progname, "cannot open options file %s\n", filename);
+ error_msg(h5tools_getprogname(), "cannot open options file %s\n", filename);
exit(EXIT_FAILURE);
}
@@ -526,7 +529,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(h5tools_getprogname(), "could not add compression option\n");
exit(EXIT_FAILURE);
}
}
@@ -556,7 +559,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(h5tools_getprogname(), "could not add chunck option\n");
exit(EXIT_FAILURE);
}
}
@@ -565,7 +568,7 @@ void read_info(const char *filename,
*-------------------------------------------------------------------------
*/
else {
- error_msg(progname, "bad file format for %s", filename);
+ error_msg(h5tools_getprogname(), "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..d1cb97a 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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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..b5753e6 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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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 e64e85a..90a3671 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -17,7 +17,6 @@
#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);
@@ -313,12 +312,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(h5tools_getprogname(), "<%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(h5tools_getprogname(), "<%s>: %s\n", fname2, H5FOPENERROR );
H5Fclose(fid1);
return -1;
}
@@ -367,7 +366,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(h5tools_getprogname(), "property lists for <%s> are different\n",trav->objs[i].name);
goto error;
}
@@ -395,7 +394,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(h5tools_getprogname(), "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 d77ba5f..57fb1ce 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -88,9 +88,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 906996a..332fcc5 100644
--- a/tools/h5repack/testh5repack_detect_szip.c
+++ b/tools/h5repack/testh5repack_detect_szip.c
@@ -19,6 +19,8 @@
#include "h5test.h"
+/* Name of tool */
+#define PROGRAMNAME "h5repack_detect_szip"
/*-------------------------------------------------------------------------
* Function: main
@@ -42,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 4554c40..0176fd5 100644
--- a/tools/h5stat/h5stat.c
+++ b/tools/h5stat/h5stat.c
@@ -22,6 +22,9 @@
#include "h5trav.h"
#include "hdf5.h"
+/* Name of tool */
+#define PROGRAMNAME "h5stat"
+
/* Parameters to control statistics gathered */
#define SIZE_SMALL_GROUPS 10
#define SIZE_SMALL_ATTRS 10
@@ -97,8 +100,6 @@ typedef struct iter_t {
} iter_t;
-const char *progname = "h5stat";
-int d_status = EXIT_SUCCESS;
static int display_all = TRUE;
static int display_file = FALSE;
static int display_file_metadata = FALSE;
@@ -393,7 +394,7 @@ group_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
* Tuesday, August 16, 2005
*
* Modifications:
- * 2/2010; Vailin Choi
+ * 2/2010; Vailin Choi
* Handle external data (brought over from trunk h5stat)
*
*-------------------------------------------------------------------------
@@ -581,7 +582,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi)
* Failure: -1
*
* Programmer: Vailin Choi; July 7th, 2009
- *
+ *
* Modifications:
* 2/2010; Vailin Choi
* Gather attribute info for named datatype
@@ -724,11 +725,11 @@ parse_command_line(int argc, const char *argv[])
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
switch ((char)opt) {
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
@@ -782,15 +783,15 @@ parse_command_line(int argc, const char *argv[])
break;
default:
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end switch */
} /* end while */
/* check for file name to be processed */
if (argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg(h5tools_getprogname(), "missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
} /* end if */
@@ -1097,18 +1098,18 @@ print_dataset_info(const iter_t *iter)
/*-------------------------------------------------------------------------
* Function: print_dataset_metadata
- *
- * Purpose: Prints file space information for datasets' metadata
- *
+ *
+ * Purpose: Prints file space information for datasets' metadata
+ *
* Return: Success: 0
- *
+ *
* Failure: Never fails
- *
+ *
* Programmer: Vailin Choi; October 2009
* Brought over from trunk h5stat.
*
*-------------------------------------------------------------------------
- */
+ */
static herr_t
print_dset_metadata(const iter_t *iter)
{
@@ -1241,7 +1242,7 @@ print_file_statistics(const iter_t *iter)
display_dset = TRUE;
display_dset_dtype_meta = TRUE;
display_attr = TRUE;
-
+
display_file_metadata = TRUE;
display_group_metadata = TRUE;
display_dset_metadata = TRUE;
@@ -1312,13 +1313,13 @@ print_statistics(const char *name, const iter_t *iter)
/*-------------------------------------------------------------------------
* Function: main
- *
+ *
* Modifications:
* 2/2010; Vailin Choi
* Get the size of user block
- *
+ *
*-------------------------------------------------------------------------
- */
+ */
int
main(int argc, const char *argv[])
{
@@ -1329,6 +1330,9 @@ main(int argc, const char *argv[])
struct handler_t *hand;
H5F_info_t finfo;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* Disable error reporting */
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
@@ -1336,7 +1340,7 @@ main(int argc, const char *argv[])
h5tools_init();
hand = parse_command_line (argc, argv);
if(!hand) {
- error_msg(progname, "unable to parse command line arguments \n");
+ error_msg(h5tools_getprogname(), "unable to parse command line arguments \n");
leave(EXIT_FAILURE);
} /* end if */
@@ -1346,7 +1350,7 @@ main(int argc, const char *argv[])
fid = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT);
if(fid < 0) {
- error_msg(progname, "unable to open file \"%s\"\n", fname);
+ error_msg(h5tools_getprogname(), "unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
} /* end if */
@@ -1355,7 +1359,7 @@ main(int argc, const char *argv[])
/* Get storge info for SOHM's btree/list/heap and superblock extension */
if(H5Fget_info(fid, &finfo) < 0)
- warn_msg(progname, "Unable to retrieve SOHM info\n");
+ warn_msg(h5tools_getprogname(), "Unable to retrieve SOHM info\n");
else {
iter.super_ext_size = finfo.super_ext_size;
iter.SM_hdr_storage_size = finfo.sohm.hdr_size;
@@ -1364,10 +1368,10 @@ main(int argc, const char *argv[])
} /* end else */
if((fcpl = H5Fget_create_plist(fid)) < 0)
- warn_msg(progname, "Unable to retrieve file creation property\n");
+ warn_msg(h5tools_getprogname(), "Unable to retrieve file creation property\n");
if(H5Pget_userblock(fcpl, &iter.ublk_size) < 0)
- warn_msg(progname, "Unable to retrieve userblock size\n");
+ warn_msg(h5tools_getprogname(), "Unable to retrieve userblock size\n");
/* Walk the objects or all file */
if(display_object) {
@@ -1376,7 +1380,7 @@ main(int argc, const char *argv[])
u = 0;
while(hand[u].obj) {
if (h5trav_visit(fid, hand[u].obj, TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0)
- warn_msg(progname, "Unable to traverse object \"%s\"\n", hand[u].obj);
+ warn_msg(h5tools_getprogname(), "Unable to traverse object \"%s\"\n", hand[u].obj);
else
print_statistics(hand[u].obj, &iter);
u++;
@@ -1384,7 +1388,7 @@ main(int argc, const char *argv[])
} /* end if */
else {
if (h5trav_visit(fid, "/", TRUE, TRUE, obj_stats, lnk_stats, &iter) < 0)
- warn_msg(progname, "Unable to traverse objects/links in file \"%s\"\n", fname);
+ warn_msg(h5tools_getprogname(), "Unable to traverse objects/links in file \"%s\"\n", fname);
else
print_statistics("/", &iter);
} /* end else */
@@ -1392,7 +1396,7 @@ main(int argc, const char *argv[])
if (hand) free(hand);
if(H5Fclose(fid) < 0) {
- error_msg(progname, "unable to close file \"%s\"\n", fname);
+ error_msg(h5tools_getprogname(), "unable to close file \"%s\"\n", fname);
leave(EXIT_FAILURE);
}
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 654cca9..ddfccf8 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";
#ifdef H5_HAVE_H5DUMP_PACKED_BITS
int packed_output; /* number of packed bits to display */
int packed_normalize; /* number of bits to shift right to display normalized */
@@ -288,6 +290,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 8c9769e..d1b569c 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -521,42 +521,50 @@ 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
#ifdef H5_HAVE_H5DUMP_PACKED_BITS
extern int packed_output; /* packed bits output count */
extern int packed_normalize; /* number of bits to shift right to display normalized */
extern unsigned int packed_counter; /* counter for which packed bits to display */
#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"
#define H5_TOOLS_DATASET "DATASET"
#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);
/*
@@ -569,5 +577,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..e18d6d3 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(h5tools_getprogname(), "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.h b/tools/lib/h5tools_utils.h
index dcd8f2b..438ca64 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 *progname, const char *fmt, ...);
+H5TOOLS_DLL void warn_msg(const char *progname, 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/lib/ph5diff.h b/tools/lib/ph5diff.h
index 3ad158f..65e2132 100644
--- a/tools/lib/ph5diff.h
+++ b/tools/lib/ph5diff.h
@@ -32,11 +32,11 @@
#define MPI_TAG_END 7
#define MPI_TAG_PARALLEL 8
-extern int g_nTasks;
-extern unsigned char g_Parallel;
-extern char outBuff[];
-extern int outBuffOffset;
-extern FILE * overflow_file;
+H5TOOLS_DLLVAR int g_nTasks;
+H5TOOLS_DLLVAR unsigned char g_Parallel;
+H5TOOLS_DLLVAR char outBuff[];
+H5TOOLS_DLLVAR int outBuffOffset;
+H5TOOLS_DLLVAR FILE * overflow_file;
struct diff_args
{
diff --git a/tools/misc/h5mkgrp.c b/tools/misc/h5mkgrp.c
index a6fdc56..eb3d3f0 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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "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(h5tools_getprogname(), "Could not close file access property list\n");
leave(EXIT_FAILURE);
} /* end if */
diff --git a/windows/src/H5pubconf.h b/windows/src/H5pubconf.h
index c5254c7..30c94d2 100755
--- a/windows/src/H5pubconf.h
+++ b/windows/src/H5pubconf.h
@@ -169,6 +169,9 @@
/* Define to 1 if you have the <gpfs.h> header file. */
/* #undef H5_HAVE_GPFS_H */
+/* Define if h5dump packed bits feature is enabled */
+#define H5_HAVE_H5DUMP_PACKED_BITS
+
/* Define if library will contain instrumentation to detect correct
optimization operation */
/* #undef H5_HAVE_INSTRUMENTED_LIBRARY */