summaryrefslogtreecommitdiffstats
path: root/tools/h5dump/h5dump.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2010-05-11 20:10:25 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2010-05-11 20:10:25 (GMT)
commit68fa42f3360945d07a0443289025a6a91618aac5 (patch)
treeca90a2cf0244915347d531bddd78e7e7d898825d /tools/h5dump/h5dump.c
parentfe49632588af7cafdd220998be6006d91ed0247c (diff)
downloadhdf5-68fa42f3360945d07a0443289025a6a91618aac5.zip
hdf5-68fa42f3360945d07a0443289025a6a91618aac5.tar.gz
hdf5-68fa42f3360945d07a0443289025a6a91618aac5.tar.bz2
[svn-r18759] pull r18757 from 1.8 branch
Enable tools lib to be built as a dll on windows. Added two get/set functions for progname and d_status. Also add windows import/export declarations to functions. Updated error_mesg() and warn_mesg() to remove progname argument and use get functions Tested: Windows, linux
Diffstat (limited to 'tools/h5dump/h5dump.c')
-rw-r--r--tools/h5dump/h5dump.c326
1 files changed, 163 insertions, 163 deletions
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 3156ba6..e4c5231 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -22,9 +22,8 @@
#include "h5tools_ref.h"
#include "h5trav.h"
-
-/* module-scoped variables */
-const char *progname = "h5dump";
+/* Name of tool */
+#define PROGRAMNAME "h5dump"
/* Macros for displaying objects */
#define begin_obj(obj,name,begin) \
@@ -68,7 +67,6 @@ typedef struct h5dump_table_list_t {
} *tables;
} h5dump_table_list_t;
-int d_status = EXIT_SUCCESS;
static int unamedtype = 0; /* shared datatype with no name */
static h5dump_table_list_t table_list = {0, 0, NULL};
static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
@@ -819,7 +817,7 @@ table_list_free(void)
for(u = 0; u < table_list.nused; u++) {
/* Release object id */
if(H5Idec_ref(table_list.tables[u].oid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
/* Free each table */
free_table(table_list.tables[u].group_table);
@@ -881,8 +879,8 @@ print_datatype(hid_t type,unsigned in_group)
else
printf("\"%s\"", obj->objname);
} else {
- error_msg(progname, "unknown committed type.\n");
- d_status = EXIT_FAILURE;
+ error_msg("unknown committed type.\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
switch(H5Tget_class(type)) {
@@ -1121,7 +1119,7 @@ print_datatype(hid_t type,unsigned in_group)
/* Type doesn't match any of above. */
printf("unknown_one_character_type;\n ");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
done:
H5Tclose(str_type);
@@ -1151,7 +1149,7 @@ print_datatype(hid_t type,unsigned in_group)
printf("H5T_STD_B64LE");
} else {
printf("undefined bitfield");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
break;
@@ -1258,7 +1256,7 @@ print_datatype(hid_t type,unsigned in_group)
default:
printf("unknown datatype");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
break;
}
} /* end else */
@@ -1401,11 +1399,11 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, vo
if((attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT)) < 0) {
indentation(indent + COL);
- error_msg(progname, "unable to open attribute \"%s\"\n", attr_name);
+ error_msg("unable to open attribute \"%s\"\n", attr_name);
indentation(indent);
end_obj(dump_header_format->attributeend,
dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
hid_t type, space;
@@ -1477,9 +1475,9 @@ dump_selected_attr(hid_t loc_id, const char *name)
/* Open the object with the attribute */
if((oid = H5Oopen(loc_id, obj_name, H5P_DEFAULT)) < 0) {
indentation(COL);
- error_msg(progname, "unable to open object \"%s\"\n", obj_name);
+ error_msg("unable to open object \"%s\"\n", obj_name);
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return FAIL;
} /* end if */
@@ -1504,14 +1502,14 @@ dump_selected_attr(hid_t loc_id, const char *name)
dump_header_format->attributeblockend);
} else {
indentation(COL);
- error_msg(progname, "unable to open attribute \"%s\"\n", obj_name);
+ error_msg("unable to open attribute \"%s\"\n", obj_name);
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
/* Close object */
if(H5Oclose(oid) < 0) {
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return FAIL;
} /* end if */
@@ -1559,8 +1557,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
/* Stat the object */
if(H5Oget_info_by_name(group, name, &oinfo, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get object information for \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to get object information for \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
goto done;
} /* end if */
@@ -1570,8 +1568,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
case H5O_TYPE_GROUP:
if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0)
{
- error_msg(progname, "unable to dump group \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to dump group \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
else
@@ -1609,13 +1607,13 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
begin_obj(dump_header_format->datasetbegin, name,
dump_header_format->datasetblockbegin);
indentation(indent + COL);
- error_msg(progname,
+ error_msg(h5tools_getprogname(),
"internal error (file %s:line %d)\n",
__FILE__, __LINE__);
indentation(indent);
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
H5Dclose(obj);
goto done;
@@ -1678,16 +1676,16 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
dump_function_table->dump_dataset_function(obj, name, NULL);
H5Dclose(obj);
} else {
- error_msg(progname, "unable to dump dataset \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to dump dataset \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
break;
case H5O_TYPE_NAMED_DATATYPE:
if((obj = H5Topen2(group, name, H5P_DEFAULT)) < 0) {
- error_msg(progname, "unable to dump datatype \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unable to dump datatype \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
dump_function_table->dump_named_datatype_function(obj, name);
@@ -1696,8 +1694,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
break;
default:
- error_msg(progname, "unknown object \"%s\"\n", name);
- d_status = EXIT_FAILURE;
+ error_msg("unknown object \"%s\"\n", name);
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
}
} /* end if */
@@ -1717,8 +1715,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
}
if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get link value\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to get link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} else {
/* print the value of a soft link */
@@ -1808,8 +1806,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
begin_obj(dump_header_format->extlinkbegin, name, dump_header_format->extlinkblockbegin);
if(H5Lget_val(group, name, targbuf, linfo->u.val_size, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get external link value\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to get external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
@@ -1817,8 +1815,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED
const char *targname;
if(H5Lunpack_elink_val(targbuf, linfo->u.val_size, NULL, &filename, &targname) < 0) {
- error_msg(progname, "unable to unpack external link value\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to unpack external link value\n");
+ h5tools_setstatus(EXIT_FAILURE);
ret = FAIL;
} /* end if */
else {
@@ -1950,20 +1948,20 @@ dump_named_datatype(hid_t tid, const char *name)
if ((tcpl_id = H5Tget_create_plist(tid)) < 0)
{
- error_msg(progname, "error in getting creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the creation properties for attributes */
if (H5Pget_attr_creation_order(tcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(H5Pclose(tcpl_id) < 0) {
- error_msg(progname, "error in closing creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in closing creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -1982,9 +1980,9 @@ dump_named_datatype(hid_t tid, const char *name)
found_obj = search_obj(type_table, oinfo.addr);
if (found_obj == NULL) {
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
else if (found_obj->displayed) {
@@ -2007,14 +2005,14 @@ dump_named_datatype(hid_t tid, const char *name)
if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(tid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(tid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2056,27 +2054,27 @@ dump_group(hid_t gid, const char *name)
if ((gcpl_id = H5Gget_create_plist(gid)) < 0)
{
- error_msg(progname, "error in getting group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties for attributes */
if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties */
if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(H5Pclose(gcpl_id) < 0) {
- error_msg(progname, "error in closing group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -2118,9 +2116,9 @@ dump_group(hid_t gid, const char *name)
if (found_obj == NULL) {
indentation(indent);
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
else if (found_obj->displayed) {
indentation(indent);
@@ -2133,14 +2131,14 @@ dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2164,14 +2162,14 @@ dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2218,15 +2216,15 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
if ((dcpl_id = H5Dget_create_plist(did)) < 0)
{
- error_msg(progname, "error in getting creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the creation properties for attributes */
if (H5Pget_attr_creation_order(dcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
indentation(indent);
@@ -2280,14 +2278,14 @@ dump_dataset(hid_t did, const char *name, struct subset_t *sset)
if( (sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_attr_cb, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -2598,8 +2596,8 @@ dump_data(hid_t obj_id, int obj_data, struct subset_t *sset, int display_index)
if (status == FAIL) {
indentation(indent + COL);
- error_msg(progname, "unable to print data\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to print data\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
indentation(indent);
@@ -3569,10 +3567,10 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
begin_obj(dump_header_format->datasetbegin, real_name,
dump_header_format->datasetblockbegin);
indentation(COL);
- error_msg(progname, "unable to open dataset \"%s\"\n", real_name);
+ error_msg("unable to open dataset \"%s\"\n", real_name);
end_obj(dump_header_format->datasetend,
dump_header_format->datasetblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
return;
} /* end if */
@@ -3639,8 +3637,8 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
if ( sset->stride[i] < sset->block[i] )
{
- error_msg(progname, "wrong subset selection; blocks overlap\n");
- d_status = EXIT_FAILURE;
+ error_msg("wrong subset selection; blocks overlap\n");
+ h5tools_setstatus(EXIT_FAILURE);
return;
}
@@ -3674,13 +3672,13 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis
}
}
else
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
else
dump_dataset(dsetid, real_name, sset);
if(H5Dclose(dsetid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
/*-------------------------------------------------------------------------
@@ -3716,9 +3714,9 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch
{
begin_obj(dump_header_format->groupbegin, real_name, dump_header_format->groupblockbegin);
indentation(COL);
- error_msg(progname, "unable to open group \"%s\"\n", real_name);
+ error_msg("unable to open group \"%s\"\n", real_name);
end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
}
else
@@ -3736,7 +3734,7 @@ handle_groups(hid_t fid, const char *group, void UNUSED * data, int pe, const ch
dump_group(gid, real_name);
if(H5Gclose(gid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
} /* end else */
} /* end handle_groups() */
@@ -3760,11 +3758,11 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co
H5L_info_t linfo;
if(H5Lget_info(fid, links, &linfo, H5P_DEFAULT) < 0) {
- error_msg(progname, "unable to get link info from \"%s\"\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("unable to get link info from \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
} else if(linfo.type == H5L_TYPE_HARD) {
- error_msg(progname, "\"%s\" is a hard link\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("\"%s\" is a hard link\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
} else {
char *buf = HDmalloc(linfo.u.val_size);
@@ -3776,9 +3774,9 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co
if(H5Lget_val(fid, links, buf, linfo.u.val_size, H5P_DEFAULT) >= 0)
printf("LINKTARGET \"%s\"\n", buf);
else {
- error_msg(progname, "h5dump error: unable to get link value for \"%s\"\n",
+ error_msg("h5dump error: unable to get link value for \"%s\"\n",
links);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
end_obj(dump_header_format->softlinkend,
dump_header_format->softlinkblockend);
@@ -3802,12 +3800,12 @@ handle_links(hid_t fid, const char *links, void UNUSED * data, int UNUSED pe, co
indentation(COL);
printf("TARGETPATH \"%s\"\n", elink_path);
} else {
- error_msg(progname, "h5dump error: unable to unpack external link value for \"%s\"\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("h5dump error: unable to unpack external link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
- error_msg(progname, "h5dump error: unable to get external link value for \"%s\"\n", links);
- d_status = EXIT_FAILURE;
+ error_msg("h5dump error: unable to get external link value for \"%s\"\n", links);
+ h5tools_setstatus(EXIT_FAILURE);
}
end_obj(dump_header_format->extlinkend,
dump_header_format->extlinkblockend);
@@ -3883,10 +3881,10 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const
begin_obj(dump_header_format->datatypebegin, real_name,
dump_header_format->datatypeblockbegin);
indentation(COL);
- error_msg(progname, "unable to open datatype \"%s\"\n", real_name);
+ error_msg("unable to open datatype \"%s\"\n", real_name);
end_obj(dump_header_format->datatypeend,
dump_header_format->datatypeblockend);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
}
else
@@ -3903,7 +3901,7 @@ handle_datatypes(hid_t fid, const char *type, void UNUSED * data, int pe, const
dump_named_datatype(type_id, real_name);
if(H5Tclose(type_id) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
}
@@ -3935,7 +3933,7 @@ parse_command_line(int argc, const char *argv[])
/* no arguments */
if (argc == 1) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
@@ -3985,7 +3983,7 @@ parse_start:
display_char = TRUE;
break;
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
leave(EXIT_SUCCESS);
break;
case 'w':
@@ -4061,13 +4059,13 @@ parse_start:
case 'o':
if ( bin_output ) {
if (set_output_file(opt_arg, 1) < 0) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
else {
if (set_output_file(opt_arg, 0) < 0) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -4081,7 +4079,7 @@ parse_start:
if ( opt_arg != NULL) {
if ( ( bin_form = set_binary_form(opt_arg)) < 0) {
/* failed to set binary form */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -4089,7 +4087,7 @@ parse_start:
if (outfname!=NULL) {
if (set_output_file(outfname, 1) < 0) {
/* failed to set output file */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
@@ -4100,7 +4098,7 @@ parse_start:
case 'q':
if ( ( sort_by = set_sort_by(opt_arg)) < 0) {
/* failed to set "sort by" form */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
break;
@@ -4108,7 +4106,7 @@ parse_start:
case 'z':
if ( ( sort_order = set_sort_order(opt_arg)) < 0) {
/* failed to set "sort order" form */
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
break;
@@ -4146,7 +4144,7 @@ parse_start:
/* specify XML namespace (default="hdf5:"), or none */
/* To Do: check format of this value? */
if (!useschema) {
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
if (strcmp(opt_arg,":") == 0) {
@@ -4165,7 +4163,7 @@ parse_start:
struct subset_t *s;
if (!last_was_dset) {
- error_msg(progname,
+ error_msg(h5tools_getprogname(),
"option `-%c' can only be used after --dataset option\n",
opt);
leave(EXIT_FAILURE);
@@ -4213,11 +4211,11 @@ end_collect:
/** end subsetting parameters **/
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_SUCCESS);
case '?':
default:
- usage(progname);
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
}
@@ -4225,8 +4223,8 @@ end_collect:
parse_end:
/* check for file name to be processed */
if (argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
return hand;
@@ -4320,6 +4318,8 @@ main(int argc, const char *argv[])
int i;
unsigned u;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
dump_header_format = &standardformat;
dump_function_table = &ddl_function_table;
@@ -4333,43 +4333,43 @@ main(int argc, const char *argv[])
if ( bin_output && outfname == NULL )
{
- error_msg(progname, "binary output requires a file name, use -o <filename>\n");
+ error_msg("binary output requires a file name, use -o <filename>\n");
leave(EXIT_FAILURE);
}
/* Check for conflicting options */
if (doxml) {
if (!display_all) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"to display selected objects");
leave(EXIT_FAILURE);
} else if (display_bb) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--boot-block");
leave(EXIT_FAILURE);
} else if (display_oid == 1) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--object-ids");
leave(EXIT_FAILURE);
} else if (display_char == TRUE) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--string");
leave(EXIT_FAILURE);
} else if (usingdasho) {
- error_msg(progname, "option \"%s\" not available for XML\n",
+ error_msg("option \"%s\" not available for XML\n",
"--output");
leave(EXIT_FAILURE);
}
} else {
if (xml_dtd_uri) {
- warn_msg(progname, "option \"%s\" only applies with XML: %s\n",
+ warn_msg("option \"%s\" only applies with XML: %s\n",
"--xml-dtd", xml_dtd_uri);
}
}
if (argc <= opt_ind) {
- error_msg(progname, "missing file name\n");
- usage(progname);
+ error_msg("missing file name\n");
+ usage(h5tools_getprogname());
leave(EXIT_FAILURE);
}
fname = HDstrdup(argv[opt_ind]);
@@ -4377,7 +4377,7 @@ main(int argc, const char *argv[])
fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
if (fid < 0) {
- error_msg(progname, "unable to open file \"%s\"\n", fname);
+ error_msg("unable to open file \"%s\"\n", fname);
leave(EXIT_FAILURE);
}
@@ -4403,7 +4403,7 @@ main(int argc, const char *argv[])
}
} else {
if (useschema && strcmp(xmlnsprefix,"")) {
- error_msg(progname, "Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
+ error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
leave(EXIT_FAILURE);
}
}
@@ -4412,15 +4412,15 @@ main(int argc, const char *argv[])
/* Get object info for root group */
if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) {
- error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* Initialize object tables */
if(table_list_add(fid, oi.fileno) < 0) {
- error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
}
group_table = table_list.tables[0].group_table;
@@ -4482,8 +4482,8 @@ main(int argc, const char *argv[])
{
if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0)
{
- error_msg(progname, "unable to open root group\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to open root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
else
{
@@ -4494,8 +4494,8 @@ main(int argc, const char *argv[])
if(H5Gclose(gid) < 0)
{
- error_msg(progname, "unable to close root group\n");
- d_status = EXIT_FAILURE;
+ error_msg("unable to close root group\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
@@ -4504,8 +4504,8 @@ main(int argc, const char *argv[])
{
/* Note: this option is not supported for XML */
if(doxml) {
- error_msg(progname, "internal error (file %s:line %d)\n", __FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
} /* end if */
@@ -4525,7 +4525,7 @@ done:
table_list_free();
if (H5Fclose(fid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
free_handler(hand, argc);
@@ -4536,7 +4536,7 @@ done:
H5Eset_auto2(H5E_DEFAULT, func, edata);
- leave(d_status);
+ leave(h5tools_getstatus());
}
/*-------------------------------------------------------------------------
@@ -4949,7 +4949,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
free(dtxid);
} else {
printf("<!-- h5dump error: unknown committed type. -->\n");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
} else {
@@ -5253,7 +5253,7 @@ xml_print_datatype(hid_t type, unsigned in_group)
default:
printf("<!-- unknown datatype -->");
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
break;
}
} /* end else */
@@ -5635,7 +5635,7 @@ xml_dump_attr(hid_t attr, const char *attr_name, const H5A_info_t UNUSED *info,
printf("<!-- h5dump error: unable to open attribute. -->\n");
indentation(indent);
printf("</%sAttribute>\n", xmlnsprefix );
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return FAIL;
}
}
@@ -5710,9 +5710,9 @@ xml_dump_named_datatype(hid_t type, const char *name)
if (found_obj == NULL) {
indentation(indent);
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
} else if(found_obj->displayed) {
/* We have already printed this named datatype, print it as a
@@ -5791,27 +5791,27 @@ xml_dump_group(hid_t gid, const char *name)
if ((gcpl_id = H5Gget_create_plist(gid)) < 0)
{
- error_msg(progname, "error in getting group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties for attributes */
if (H5Pget_attr_creation_order(gcpl_id, &attr_crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
/* query the group creation properties */
if(H5Pget_link_creation_order(gcpl_id, &crt_order_flags) < 0)
{
- error_msg(progname, "error in getting group creation properties\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in getting group creation properties\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(H5Pclose(gcpl_id) < 0) {
- error_msg(progname, "error in closing group creation property list ID\n");
- d_status = EXIT_FAILURE;
+ error_msg("error in closing group creation property list ID\n");
+ h5tools_setstatus(EXIT_FAILURE);
}
if(HDstrcmp(name, "/") == 0) {
@@ -5843,9 +5843,9 @@ xml_dump_group(hid_t gid, const char *name)
if (found_obj == NULL) {
indentation(indent);
- error_msg(progname, "internal error (file %s:line %d)\n",
+ error_msg("internal error (file %s:line %d)\n",
__FILE__, __LINE__);
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
} else {
char *t_name = xml_escape_the_name(name);
char *grpxid = malloc(100);
@@ -5910,14 +5910,14 @@ xml_dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -5982,14 +5982,14 @@ xml_dump_group(hid_t gid, const char *name)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(gid, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(gid, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -6648,14 +6648,14 @@ xml_dump_dataset(hid_t did, const char *name, struct subset_t UNUSED * sset)
if((sort_by == H5_INDEX_CRT_ORDER) && (attr_crt_order_flags & H5P_CRT_ORDER_TRACKED)) {
if(H5Aiterate2(did, sort_by, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end if */
else {
if(H5Aiterate2(did, H5_INDEX_NAME, sort_order, NULL, dump_function_table->dump_attribute_function, NULL) < 0) {
- error_msg(progname, "error getting attribute information\n");
- d_status = EXIT_FAILURE;
+ error_msg("error getting attribute information\n");
+ h5tools_setstatus(EXIT_FAILURE);
} /* end if */
} /* end else */
@@ -7088,7 +7088,7 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname)
handle_datatypes(group, linkname, NULL, 0, objname);
break;
default:
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
}
indent -= 2*COL;
@@ -7103,7 +7103,7 @@ static int dump_extlink(hid_t group, const char *linkname, const char *objname)
} /* end if */
if (H5Idec_ref(oid) < 0)
- d_status = EXIT_FAILURE;
+ h5tools_setstatus(EXIT_FAILURE);
return SUCCEED;