1998-09-28 22:59:49 +08:00
|
|
|
#include "h5dump.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "H5private.h"
|
1999-05-13 23:40:25 +08:00
|
|
|
#include "h5tools.h"
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1999-09-18 01:20:13 +08:00
|
|
|
static int display_oid = 0;
|
1998-09-28 22:59:49 +08:00
|
|
|
static int display_data = 1;
|
2000-04-13 23:19:12 +08:00
|
|
|
static int d_status = 0;
|
1998-10-29 14:27:31 +08:00
|
|
|
static int unamedtype = 0; /* shared data type with no name */
|
|
|
|
|
|
|
|
static int prefix_len = 1024;
|
|
|
|
static char *prefix;
|
1999-10-30 03:50:25 +08:00
|
|
|
static table_t *group_table = NULL, *dset_table = NULL, *type_table = NULL;
|
2000-03-10 08:41:10 +08:00
|
|
|
static const dump_header *dump_header_format;
|
2000-03-10 01:53:48 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
static void dump_group (hid_t , const char* );
|
1998-09-28 22:59:49 +08:00
|
|
|
static void dump_dataset (hid_t, const char*);
|
1998-09-01 03:52:53 +08:00
|
|
|
static void dump_data (hid_t, int);
|
|
|
|
static void dump_named_datatype (hid_t , const char *);
|
1999-10-30 03:50:25 +08:00
|
|
|
|
1999-02-01 16:46:29 +08:00
|
|
|
void indentation(int);
|
1999-06-14 10:40:52 +08:00
|
|
|
static void print_enum(hid_t type);
|
1999-02-01 16:46:29 +08:00
|
|
|
|
|
|
|
extern int print_data(hid_t, hid_t, int);
|
1999-09-18 01:20:13 +08:00
|
|
|
static void dump_oid(hid_t oid);
|
2000-03-10 01:53:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
static h5dump_t dataformat = {
|
|
|
|
|
|
|
|
0,/*raw*/
|
|
|
|
|
|
|
|
"", /*fmt_raw*/
|
|
|
|
"%d", /*fmt_int*/
|
|
|
|
"%u", /*fmt_uint*/
|
|
|
|
"%d", /*fmt_schar*/
|
|
|
|
"%u", /*fmt_uchar*/
|
|
|
|
"%d", /*fmt_short*/
|
|
|
|
"%u", /*fmt_ushort*/
|
|
|
|
"%ld", /*fmt_long*/
|
|
|
|
"%lu", /*fmt_ulong*/
|
|
|
|
NULL, /*fmt_llong*/
|
|
|
|
NULL, /*fmt_ullong*/
|
|
|
|
"%g", /*fmt_double*/
|
|
|
|
"%g", /*fmt_float*/
|
|
|
|
|
|
|
|
0, /*ascii*/
|
|
|
|
0, /*str_locale*/
|
|
|
|
0,/*str_repeat*/
|
|
|
|
|
|
|
|
|
|
|
|
"[ ", /*arr_pre*/
|
|
|
|
", ", /*arr_sep*/
|
|
|
|
" ]", /*arr_suf*/
|
|
|
|
1, /*arr_linebreak*/
|
|
|
|
|
|
|
|
"", /*cmpd_name*/
|
|
|
|
",\n",/*cmpd_sep*/
|
|
|
|
"{\n",/*cmpd_pre*/
|
|
|
|
"}",/*cmpd_suf*/
|
|
|
|
"\n",/*cmpd_end*/
|
|
|
|
|
|
|
|
"%s", /*elmt_fmt*/
|
|
|
|
",",/*elmt_suf1*/
|
|
|
|
" ", /*elmt_suf2*/
|
|
|
|
|
|
|
|
"", /*idx_n_fmt*/
|
|
|
|
"",/*idx_sep*/
|
|
|
|
"",/*idx_fmt*/
|
|
|
|
|
|
|
|
80, /*line_ncols*//*standard default columns*/
|
|
|
|
0, /*line_per_line*/
|
2000-04-20 02:08:11 +08:00
|
|
|
"",/*line_pre*/
|
|
|
|
"%s",/*line_1st*/
|
|
|
|
"%s",/*line_cont*/
|
2000-03-10 01:53:48 +08:00
|
|
|
"",/*line_suf*/
|
|
|
|
"",/*line_sep*/
|
|
|
|
1,/*line_multi_new*/
|
|
|
|
" ",/*line_indent*/
|
|
|
|
|
|
|
|
1, /*skip_first*/
|
|
|
|
|
|
|
|
1,/*obj_hidefileno*/
|
|
|
|
" %lu:%lu", /*obj_format*/
|
|
|
|
|
|
|
|
1, /*dset_hidefileno*/
|
|
|
|
"DATASET %lu:%lu ",/*dset_format*/
|
|
|
|
"%s",/*dset_blockformat_pre*/
|
|
|
|
"%s",/*dset_ptformat_pre*/
|
|
|
|
"%s",/*dset_ptformat*/
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
static const dump_header standardformat = {
|
|
|
|
"standardformat", /*name*/
|
|
|
|
"HDF5", /*fileebgin*/
|
|
|
|
"", /*fileend*/
|
|
|
|
BOOT_BLOCK, /*bootblockbegin*/
|
|
|
|
"", /*bootblockend*/
|
|
|
|
GROUPNAME, /*groupbegin*/
|
|
|
|
"", /*groupend*/
|
|
|
|
DATASET, /*datasetbegin*/
|
|
|
|
"", /*datasetend*/
|
|
|
|
ATTRIBUTE, /*attributebegin*/
|
|
|
|
"", /*attributeend*/
|
|
|
|
DATATYPE, /*datatypebegin*/
|
|
|
|
"", /*datatypeend*/
|
|
|
|
DATASPACE, /*dataspacebegin*/
|
|
|
|
"", /*dataspaceend*/
|
|
|
|
DATA, /*databegin*/
|
|
|
|
"", /*dataend*/
|
|
|
|
SOFTLINK, /*softlinkbegin*/
|
|
|
|
"", /*softlinkend*/
|
|
|
|
|
|
|
|
|
|
|
|
"{", /*fileblockbegin*/
|
|
|
|
"}", /*fileblockend*/
|
|
|
|
"{", /*bootblockblockbegin*/
|
|
|
|
"}", /*bootblockblockend*/
|
|
|
|
"{", /*groupblockbegin*/
|
|
|
|
"}", /*groupblockend*/
|
|
|
|
"{", /*datasetblockbegin*/
|
|
|
|
"}", /*datasetblockend*/
|
|
|
|
"{", /*attributeblockbegin*/
|
|
|
|
"}", /*attributeblockend*/
|
|
|
|
"{", /*datatypeblockbegin*/
|
|
|
|
"}", /*datatypeblockend*/
|
|
|
|
"{", /*dataspaceblockbegin*/
|
|
|
|
"}", /*dataspaceblockend*/
|
|
|
|
"{", /*datablockbegin*/
|
|
|
|
"}", /*datablockend*/
|
|
|
|
"{", /*softlinkblockbegin*/
|
|
|
|
"}", /*softlinkblockend*/
|
|
|
|
"{", /*strblockbegin*/
|
|
|
|
"}", /*strblockend*/
|
|
|
|
"{", /*enumblockbegin*/
|
|
|
|
"}", /*enumblockend*/
|
|
|
|
|
|
|
|
"{", /*dataspacedescriptionbegin*/
|
|
|
|
"}", /*dataspacedescriptionend*/
|
|
|
|
"(", /*dataspacedimbegin*/
|
|
|
|
")", /*dataspacedimend*/
|
|
|
|
};
|
|
|
|
|
|
|
|
static const dump_header xmlformat = {
|
2000-03-10 02:10:52 +08:00
|
|
|
"xml", /*name*/
|
|
|
|
"<FILE>", /*filebegin*/
|
|
|
|
"</FILE>", /*fileend*/
|
|
|
|
"<BOOTBLOCK>", /*bootblockbegin*/
|
|
|
|
"</BOOTBLOCK>", /*bootblockend*/
|
|
|
|
"<GROUP>", /*groupbegin*/
|
2000-03-10 02:38:09 +08:00
|
|
|
"</GROUP>", /*groupend*/
|
2000-03-10 02:10:52 +08:00
|
|
|
"<DATASET>", /*datasetbegin*/
|
|
|
|
"</DATASET>", /*datasetend*/
|
|
|
|
"<ATTRIBUTE>", /*attributebegin*/
|
|
|
|
"</ATTRIBUTE>", /*attributeend*/
|
|
|
|
"<DATATYPE>", /*datatypeend*/
|
|
|
|
"</DATATYPE>", /*datatypeend*/
|
|
|
|
"<DATASPACE>", /*dataspacebegin*/
|
|
|
|
"</DATASPACE>", /*dataspaceend*/
|
|
|
|
"<DATA>", /*databegin*/
|
|
|
|
"</DATA>", /*dataend*/
|
|
|
|
"<SOFTLINK>", /*softlinkbegin*/
|
|
|
|
"</SOFTLINK>", /*softlinkend*/
|
|
|
|
|
|
|
|
"", /*fileblockbegin*/
|
|
|
|
"", /*fileblockend*/
|
|
|
|
"", /*bootblockblockbegin*/
|
|
|
|
"", /*bootblockblockend*/
|
|
|
|
"", /*groupblockbegin*/
|
|
|
|
"", /*groupblockend*/
|
|
|
|
"", /*datasetblockbegin*/
|
|
|
|
"", /*datasetblockend*/
|
|
|
|
"", /*attributeblockbegin*/
|
|
|
|
"", /*attributeblockend*/
|
|
|
|
"", /*datatypeblockbegin*/
|
|
|
|
"", /*datatypeblockend*/
|
|
|
|
"", /*dataspaceblockbegin*/
|
|
|
|
"", /*dataspaceblockend*/
|
|
|
|
"", /*datablockbegin*/
|
|
|
|
"", /*datablockend*/
|
|
|
|
"", /*softlinkblockbegin*/
|
|
|
|
"", /*softlinkblockend*/
|
2000-03-10 01:53:48 +08:00
|
|
|
"", /*strblockbegin*/
|
|
|
|
"", /*strblockend*/
|
|
|
|
"", /*enumblockbegin*/
|
|
|
|
"", /*enumblockend*/
|
|
|
|
|
2000-03-10 02:42:53 +08:00
|
|
|
"", /*dataspacedescriptionbegin*/
|
|
|
|
"", /*dataspacedescriptionend*/
|
2000-03-10 02:10:52 +08:00
|
|
|
"(", /*dataspacedimbegin*/
|
|
|
|
")", /*dataspacedimend*/
|
2000-03-10 01:53:48 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: usage
|
|
|
|
*
|
|
|
|
* Purpose: Print the usage message about dumper
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-01 03:52:53 +08:00
|
|
|
usage(void)
|
1998-08-20 05:46:55 +08:00
|
|
|
{
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf(stderr,
|
|
|
|
"\nUsage of HDF5 Dumper:\n\n \
|
2000-05-31 00:54:44 +08:00
|
|
|
h5dump [-h] [-bb] [-header] [-v] [-V] [-a <names>] [-d <names>] [-g <names>]\n \
|
1999-09-18 01:20:13 +08:00
|
|
|
[-l <names>] [-t <names>] [-w <number>] <file>\n\n\
|
1999-12-11 04:44:04 +08:00
|
|
|
-h Print information on this command and exit.\n\
|
1998-10-29 14:27:31 +08:00
|
|
|
-bb Display the conent of the boot block. The default is not to display.\n\
|
|
|
|
-header Display header only; no data is displayed.\n\
|
1999-12-11 04:44:04 +08:00
|
|
|
-v Display the object ids\n\
|
|
|
|
-V Display version information and exit.\n\
|
1998-09-28 22:59:49 +08:00
|
|
|
-a <names> Display the specified attribute(s).\n\
|
|
|
|
-d <names> Display the specified dataset(s).\n\
|
1998-10-29 14:27:31 +08:00
|
|
|
-g <names> Display the specified group(s) and all the members.\n\
|
|
|
|
-l <names> Displays the value(s) of the specified soft link(s).\n\
|
|
|
|
-t <names> Display the specified named data type(s).\n\
|
1999-09-18 01:20:13 +08:00
|
|
|
-w <number> Display the information with the specified maximum number of columns.\n\
|
1998-10-29 14:27:31 +08:00
|
|
|
\n\
|
1999-09-18 01:20:13 +08:00
|
|
|
<names> is one or more appropriate object names.\n\
|
|
|
|
<number> is an integer greater than 1.\n\n");
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
1998-10-29 14:27:31 +08:00
|
|
|
* Function: print_datatype
|
1998-08-20 05:46:55 +08:00
|
|
|
*
|
1998-10-29 14:27:31 +08:00
|
|
|
* Purpose: print the data type.
|
1998-08-20 05:46:55 +08:00
|
|
|
*
|
1998-09-28 22:59:49 +08:00
|
|
|
* Return: void
|
1998-08-20 05:46:55 +08:00
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
1998-09-28 22:59:49 +08:00
|
|
|
static void
|
1998-10-29 14:27:31 +08:00
|
|
|
print_datatype(hid_t type) {
|
|
|
|
char *fname ;
|
1998-12-22 06:45:01 +08:00
|
|
|
hid_t nmembers, mtype, str_type;
|
|
|
|
int i, j, ndims, perm[H5DUMP_MAX_RANK];
|
|
|
|
size_t dims[H5DUMP_MAX_RANK], size;
|
|
|
|
H5T_str_t str_pad;
|
|
|
|
H5T_cset_t cset;
|
1998-10-29 14:27:31 +08:00
|
|
|
H5G_stat_t statbuf;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1999-06-12 01:01:51 +08:00
|
|
|
hid_t super;
|
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
switch (H5Tget_class(type)) {
|
|
|
|
|
|
|
|
case H5T_INTEGER:
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
if (H5Tequal(type, H5T_STD_I8BE))
|
|
|
|
printf( "H5T_STD_I8BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I8LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I8LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I16BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I16BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I16LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I16LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I32BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I32BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I32LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I32LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I64BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I64BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_I64LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_I64LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U8BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U8BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U8LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U8LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U16BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U16BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U16LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U16LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U32BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U32BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U32LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U32LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U64BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U64BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_U64LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_U64LE");
|
1998-11-26 01:21:21 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_SCHAR))
|
|
|
|
printf( "H5T_NATIVE_SCHAR");
|
1998-09-28 22:59:49 +08:00
|
|
|
else if (H5Tequal(type, H5T_NATIVE_UCHAR))
|
|
|
|
printf( "H5T_NATIVE_UCHAR");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_SHORT))
|
|
|
|
printf( "H5T_NATIVE_SHORT");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_USHORT))
|
|
|
|
printf( "H5T_NATIVE_USHORT");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_INT))
|
|
|
|
printf( "H5T_NATIVE_INT");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_UINT))
|
|
|
|
printf( "H5T_NATIVE_UINT");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LONG))
|
|
|
|
printf( "H5T_NATIVE_LONG");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_ULONG))
|
|
|
|
printf( "H5T_NATIVE_ULONG");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LLONG))
|
|
|
|
printf( "H5T_NATIVE_LLONG");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_ULLONG))
|
|
|
|
printf( "H5T_NATIVE_ULLONG");
|
1998-10-29 14:27:31 +08:00
|
|
|
else {
|
|
|
|
printf( "undefined integer");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
case H5T_FLOAT:
|
1998-09-28 22:59:49 +08:00
|
|
|
if (H5Tequal(type, H5T_IEEE_F32BE))
|
|
|
|
printf( "H5T_IEEE_F32BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_IEEE_F32LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_IEEE_F32LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_IEEE_F64BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_IEEE_F64BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_IEEE_F64LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_IEEE_F64LE");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_FLOAT))
|
|
|
|
printf( "H5T_NATIVE_FLOAT");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_DOUBLE))
|
|
|
|
printf( "H5T_NATIVE_DOUBLE");
|
|
|
|
else if (H5Tequal(type, H5T_NATIVE_LDOUBLE))
|
|
|
|
printf( "H5T_NATIVE_LDOUBLE");
|
1998-10-29 14:27:31 +08:00
|
|
|
else {
|
|
|
|
printf( "undefined float");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
case H5T_TIME:
|
1998-10-29 14:27:31 +08:00
|
|
|
printf( "H5T_TIME: not yet implemented");
|
1998-12-22 06:45:01 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
case H5T_STRING:
|
|
|
|
|
1998-12-22 06:45:01 +08:00
|
|
|
size = H5Tget_size(type);
|
|
|
|
str_pad = H5Tget_strpad(type) ;
|
|
|
|
cset = H5Tget_cset(type);
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf("%s %s %d;\n", dump_header_format->strblockbegin, STRSIZE, (int)size);
|
1998-12-22 06:45:01 +08:00
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-12-22 06:45:01 +08:00
|
|
|
printf(" %s ", STRPAD);
|
|
|
|
if (str_pad == H5T_STR_NULLTERM )
|
|
|
|
|
|
|
|
printf("H5T_STR_NULLTERM;\n");
|
|
|
|
|
|
|
|
else if (str_pad == H5T_STR_NULLPAD )
|
|
|
|
|
|
|
|
printf("H5T_STR_NULLPAD;\n");
|
|
|
|
|
|
|
|
else if (str_pad == H5T_STR_SPACEPAD )
|
|
|
|
|
|
|
|
printf("H5T_STR_SPACEPAD;\n");
|
|
|
|
|
|
|
|
else
|
|
|
|
printf("H5T_STR_ERROR;\n");
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-12-22 06:45:01 +08:00
|
|
|
printf(" %s ", CSET);
|
|
|
|
if (cset == H5T_CSET_ASCII)
|
|
|
|
printf("H5T_CSET_ASCII;\n");
|
|
|
|
else
|
|
|
|
printf("unknown_cset;\n");
|
|
|
|
|
|
|
|
str_type = H5Tcopy(H5T_C_S1);
|
|
|
|
H5Tset_cset(str_type, cset ) ;
|
|
|
|
H5Tset_size(str_type, size);
|
|
|
|
H5Tset_strpad(str_type, str_pad);
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-12-22 06:45:01 +08:00
|
|
|
printf(" %s ", CTYPE);
|
|
|
|
if (H5Tequal(type,str_type)) {
|
|
|
|
printf("H5T_C_S1;\n");
|
|
|
|
H5Tclose(str_type);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
H5Tclose(str_type);
|
|
|
|
str_type = H5Tcopy(H5T_FORTRAN_S1);
|
|
|
|
H5Tset_cset(str_type, cset ) ;
|
|
|
|
H5Tset_size(str_type, size);
|
|
|
|
H5Tset_strpad(str_type, str_pad );
|
|
|
|
if (H5Tequal(type,str_type))
|
|
|
|
printf( "H5T_FORTRAN_S1;\n");
|
|
|
|
else {
|
|
|
|
printf("unknown_one_character_type;\n ");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-12-22 06:45:01 +08:00
|
|
|
}
|
|
|
|
H5Tclose(str_type);
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf("%s", dump_header_format->strblockend);
|
1998-12-22 06:45:01 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
case H5T_BITFIELD:
|
|
|
|
|
|
|
|
if (H5Tequal(type, H5T_STD_B8BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B8BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B8LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B8LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B16BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B16BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B16LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B16LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B32BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B32BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B32LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B32LE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B64BE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B64BE");
|
1998-08-20 05:46:55 +08:00
|
|
|
else if (H5Tequal(type, H5T_STD_B64LE))
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "H5T_STD_B64LE");
|
1998-10-29 14:27:31 +08:00
|
|
|
else {
|
|
|
|
printf( "undefined bitfield");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
case H5T_OPAQUE:
|
2000-05-05 01:05:09 +08:00
|
|
|
printf( "\n");
|
2000-05-12 06:18:44 +08:00
|
|
|
indentation (indent+COL);
|
2000-05-10 01:00:38 +08:00
|
|
|
printf("H5T_OPAQUE;\n");
|
2000-05-12 06:18:44 +08:00
|
|
|
indentation (indent+COL);
|
2000-05-10 01:00:38 +08:00
|
|
|
printf("OPAQUE_TAG \"%s\";\n", H5Tget_tag(type));
|
2000-05-05 01:05:09 +08:00
|
|
|
indentation (indent);
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
case H5T_COMPOUND:
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
if (H5Tcommitted(type) > 0) {
|
|
|
|
H5Gget_objinfo(type, ".", TRUE, &statbuf);
|
|
|
|
|
|
|
|
i = search_obj (type_table, statbuf.objno);
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-10-29 14:27:31 +08:00
|
|
|
if (i >= 0) {
|
1999-12-18 03:06:39 +08:00
|
|
|
if (!type_table->objs[i].recorded)
|
1999-10-30 03:50:25 +08:00
|
|
|
printf("\"/#%lu:%lu\"\n", type_table->objs[i].objno[0],
|
|
|
|
type_table->objs[i].objno[1]);
|
1998-10-29 14:27:31 +08:00
|
|
|
else
|
1999-10-30 03:50:25 +08:00
|
|
|
printf("\"%s\"\n", type_table->objs[i].objname);
|
1998-10-29 14:27:31 +08:00
|
|
|
} else {
|
|
|
|
printf("h5dump error: unknown committed type.\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
nmembers = H5Tget_nmembers(type);
|
|
|
|
|
|
|
|
for (i = 0; i < nmembers; i++) {
|
|
|
|
fname = H5Tget_member_name(type, i);
|
|
|
|
|
|
|
|
mtype = H5Tget_member_type(type, i);
|
|
|
|
|
|
|
|
ndims = H5Tget_member_dims(type, i, dims, perm);
|
|
|
|
|
1999-12-04 03:26:25 +08:00
|
|
|
if (H5Tget_class(mtype) != H5T_STRING)/* && (H5Tget_class(mtype) != H5T_COMPOUND))*/
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1999-12-04 03:26:25 +08:00
|
|
|
if (H5Tget_class(mtype) == H5T_COMPOUND) {
|
|
|
|
indent += COL;
|
|
|
|
printf("{\n");
|
|
|
|
}
|
1998-10-29 14:27:31 +08:00
|
|
|
print_datatype(mtype);
|
1999-12-04 03:26:25 +08:00
|
|
|
if (H5Tget_class(mtype) == H5T_COMPOUND) {
|
|
|
|
indent -= COL;
|
|
|
|
indentation (indent+COL);
|
|
|
|
printf("}");
|
|
|
|
}
|
1998-12-22 06:45:01 +08:00
|
|
|
printf (" \"%s\"", fname);
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
if (ndims != 1 || dims[0] != 1) {
|
|
|
|
for (j = 0; j < ndims; j++)
|
1999-11-18 06:00:15 +08:00
|
|
|
printf("[%d]",(int)dims[j]);
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
printf (";\n");
|
|
|
|
|
|
|
|
free (fname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1999-06-10 02:43:07 +08:00
|
|
|
case H5T_REFERENCE:
|
|
|
|
printf("H5T_REFERENCE");
|
|
|
|
break;
|
1999-06-12 01:01:51 +08:00
|
|
|
case H5T_ENUM:
|
1999-06-23 03:10:18 +08:00
|
|
|
printf("H5T_ENUM\n");
|
1999-12-04 03:26:25 +08:00
|
|
|
indentation(indent + COL);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf("%s ", dump_header_format->enumblockbegin);
|
1999-06-12 01:01:51 +08:00
|
|
|
super = H5Tget_super(type);
|
|
|
|
print_datatype(super);
|
1999-06-23 03:10:18 +08:00
|
|
|
printf(";");
|
1999-06-14 10:40:52 +08:00
|
|
|
print_enum(type);
|
1999-06-23 22:58:51 +08:00
|
|
|
printf("\n");
|
1999-12-04 03:26:25 +08:00
|
|
|
indentation (indent + COL);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf("%s", dump_header_format->enumblockend);
|
1999-06-12 01:01:51 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
default:
|
1998-09-28 22:59:49 +08:00
|
|
|
printf( "unknown data type");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_bb
|
|
|
|
*
|
|
|
|
* Purpose: Dump the boot block
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-28 22:59:49 +08:00
|
|
|
dump_bb(void) {
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
printf ("%s %s boot block not yet implemented %s\n", BOOT_BLOCK, BEGIN, END);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_datatype
|
|
|
|
*
|
|
|
|
* Purpose: Dump the data type. Data type can be HDF5 predefined
|
1998-10-29 14:27:31 +08:00
|
|
|
* atomic data type or committed/transient data type.
|
1998-08-20 05:46:55 +08:00
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
dump_datatype (hid_t type) {
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indent += COL;
|
1998-10-29 14:27:31 +08:00
|
|
|
indentation (indent);
|
1999-02-01 16:46:29 +08:00
|
|
|
if (H5Tget_class(type) == H5T_COMPOUND) {
|
2000-03-10 01:53:48 +08:00
|
|
|
printf ("%s %s\n", dump_header_format->datatypebegin , dump_header_format->datatypeblockbegin);
|
1999-02-01 16:46:29 +08:00
|
|
|
print_datatype(type);
|
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf ("%s %s\n", dump_header_format->datatypeblockend, dump_header_format->datatypeend);
|
|
|
|
|
1999-02-01 16:46:29 +08:00
|
|
|
} else if (H5Tget_class(type) == H5T_STRING) {
|
2000-03-10 01:53:48 +08:00
|
|
|
printf ("%s %s\n", dump_header_format->datatypebegin, dump_header_format->datatypeblockbegin);
|
1998-10-29 14:27:31 +08:00
|
|
|
print_datatype(type);
|
1999-02-01 16:46:29 +08:00
|
|
|
printf("\n");
|
1998-10-29 14:27:31 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf ("%s %s\n", dump_header_format->datatypeblockend, dump_header_format->datatypeend);
|
1998-10-29 14:27:31 +08:00
|
|
|
} else {
|
2000-03-10 01:53:48 +08:00
|
|
|
printf ("%s %s ", dump_header_format->datatypebegin, dump_header_format->datatypeblockbegin);
|
1998-10-29 14:27:31 +08:00
|
|
|
print_datatype(type);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf (" %s %s\n", dump_header_format->datatypeblockend, dump_header_format->datatypeend);
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
1999-05-13 23:18:12 +08:00
|
|
|
indent -= COL;
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_dataspace
|
|
|
|
*
|
|
|
|
* Purpose: Dump the data space. Data space can be named data space,
|
|
|
|
* array, or others.
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-09-01 11:35:23 +08:00
|
|
|
dump_dataspace (hid_t space)
|
|
|
|
{
|
1998-12-22 06:45:01 +08:00
|
|
|
hsize_t size[H5DUMP_MAX_RANK];
|
|
|
|
hsize_t maxsize[H5DUMP_MAX_RANK];
|
1998-09-01 11:35:23 +08:00
|
|
|
int ndims = H5Sget_simple_extent_dims(space, size, maxsize);
|
|
|
|
int i;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
printf("%s ", dump_header_format->dataspacebegin);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
if (H5Sis_simple(space)) {
|
|
|
|
|
1998-12-22 06:45:01 +08:00
|
|
|
if (ndims == 0) /* scalar dataspace */
|
2000-03-10 01:53:48 +08:00
|
|
|
HDfprintf (stdout, "%s %s ", dump_header_format->dataspacedescriptionbegin, SCALAR);
|
1998-12-22 06:45:01 +08:00
|
|
|
else { /* simple dataspace */
|
2000-03-10 01:53:48 +08:00
|
|
|
HDfprintf (stdout, "%s %s %s %Hu",dump_header_format->dataspacedescriptionbegin, SIMPLE,
|
|
|
|
dump_header_format->dataspacedimbegin,size[0]);
|
1998-10-29 14:27:31 +08:00
|
|
|
for (i = 1; i < ndims; i++)
|
|
|
|
HDfprintf (stdout, ", %Hu", size[i]);
|
2000-03-10 01:53:48 +08:00
|
|
|
printf(" %s / ",dump_header_format->dataspacedimend);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
if (maxsize[0]==H5S_UNLIMITED)
|
2000-03-10 01:53:48 +08:00
|
|
|
HDfprintf (stdout, "%s %s", dump_header_format->dataspacedimbegin,"H5S_UNLIMITED");
|
1998-10-29 14:27:31 +08:00
|
|
|
else
|
2000-03-10 01:53:48 +08:00
|
|
|
HDfprintf (stdout, "%s %Hu", dump_header_format->dataspacedimbegin,maxsize[0]);
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
for (i = 1; i < ndims; i++)
|
|
|
|
if (maxsize[i]==H5S_UNLIMITED)
|
|
|
|
HDfprintf (stdout, ", %s", "H5S_UNLIMITED");
|
|
|
|
else
|
|
|
|
HDfprintf (stdout, ", %Hu", maxsize[i]);
|
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
printf(" %s ", dump_header_format->dataspacedimend);
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
} else
|
|
|
|
printf("%s not yet implemented %s\n", BEGIN, END);
|
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->dataspaceend, dump_header_format->dataspaceblockend);
|
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_attr
|
|
|
|
*
|
|
|
|
* Purpose: dump the attribute
|
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
*
|
|
|
|
* Failure: FAIL
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static herr_t
|
1999-04-16 03:57:50 +08:00
|
|
|
dump_attr (hid_t attr, const char *attr_name, void UNUSED *op_data)
|
1998-08-20 05:46:55 +08:00
|
|
|
{
|
|
|
|
hid_t attr_id, type, space;
|
|
|
|
|
|
|
|
indentation(indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj (dump_header_format->attributebegin, attr_name, dump_header_format->attributeblockbegin);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
if ((attr_id = H5Aopen_name (attr, attr_name))>= 0) {
|
|
|
|
|
|
|
|
type = H5Aget_type(attr_id);
|
|
|
|
space = H5Aget_space(attr_id);
|
|
|
|
dump_datatype(type);
|
1998-09-01 03:52:53 +08:00
|
|
|
dump_dataspace(space);
|
1999-09-18 01:20:13 +08:00
|
|
|
if (display_oid){
|
|
|
|
dump_oid(attr_id);
|
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
if (display_data) dump_data(attr_id, ATTRIBUTE_DATA);
|
1998-08-20 05:46:55 +08:00
|
|
|
H5Tclose(type);
|
|
|
|
H5Sclose(space);
|
1999-06-10 02:43:07 +08:00
|
|
|
H5Aclose (attr_id);
|
1998-09-28 22:59:49 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend,dump_header_format->attributeblockend );
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
} else {
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
printf("h5dump error: unable to open attribute.\n");
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend,dump_header_format->attributeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-08-20 05:46:55 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SUCCEED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_selected_attr
|
|
|
|
*
|
|
|
|
* Purpose: dump the selected attribute
|
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
*
|
|
|
|
* Failure: FAIL
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static herr_t
|
|
|
|
dump_selected_attr (hid_t loc_id, char *name)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
char *obj_name, *attr_name;
|
|
|
|
hid_t oid, attr_id, type, space;
|
|
|
|
H5G_stat_t statbuf;
|
|
|
|
|
1999-11-18 06:00:15 +08:00
|
|
|
j = (int)strlen(name)-1;
|
1998-12-22 06:45:01 +08:00
|
|
|
obj_name = malloc ((j+2)* sizeof(char));
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
/* find the last / */
|
|
|
|
while (name[j] != '/' && j >=0) j--;
|
1998-12-22 06:45:01 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
/* object name */
|
|
|
|
if (j == -1) strcpy(obj_name, "/");
|
1998-12-22 06:45:01 +08:00
|
|
|
else {
|
|
|
|
strncpy(obj_name, name, j+1);
|
|
|
|
obj_name[j+1] = '\0';
|
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
|
1998-12-22 06:45:01 +08:00
|
|
|
attr_name = name+j+1;
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj (dump_header_format->attributebegin, name, dump_header_format->attributeblockbegin);
|
1998-09-28 22:59:49 +08:00
|
|
|
|
1998-12-22 06:45:01 +08:00
|
|
|
H5Gget_objinfo(loc_id, obj_name, FALSE , &statbuf);
|
1998-09-28 22:59:49 +08:00
|
|
|
switch (statbuf.type) {
|
|
|
|
case H5G_GROUP:
|
|
|
|
if ((oid = H5Gopen (loc_id, obj_name))<0) {
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n", obj_name);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5G_DATASET:
|
|
|
|
if ((oid = H5Dopen (loc_id, obj_name))<0) {
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n", obj_name);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5G_TYPE:
|
|
|
|
if ((oid = H5Topen(loc_id, obj_name)) < 0 ) {
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n", obj_name);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n", obj_name);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((attr_id = H5Aopen_name (oid, attr_name))>= 0) {
|
|
|
|
|
|
|
|
type = H5Aget_type(attr_id);
|
|
|
|
space = H5Aget_space(attr_id);
|
|
|
|
dump_datatype(type);
|
|
|
|
dump_dataspace(space);
|
1999-10-02 05:56:00 +08:00
|
|
|
if (display_oid){
|
1999-09-18 01:20:13 +08:00
|
|
|
dump_oid(attr_id);
|
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
if (display_data) dump_data(attr_id, ATTRIBUTE_DATA);
|
|
|
|
H5Tclose(type);
|
|
|
|
H5Sclose(space);
|
1999-09-18 01:20:13 +08:00
|
|
|
H5Aclose (attr_id);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
|
1998-09-28 22:59:49 +08:00
|
|
|
|
|
|
|
} else {
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
printf("h5dump error: unable to open attribute.\n");
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (statbuf.type) {
|
|
|
|
case H5G_GROUP:
|
|
|
|
if (H5Gclose (oid) < 0) {
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5G_DATASET:
|
|
|
|
if (H5Dclose (oid) < 0 ) {
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case H5G_TYPE:
|
|
|
|
if (H5Tclose(oid) < 0 ) {
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
return FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(obj_name);
|
|
|
|
return SUCCEED;
|
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump all
|
|
|
|
*
|
|
|
|
* Purpose: Dump everything in the specified object
|
|
|
|
*
|
|
|
|
* Return: Success: SUCCEED
|
|
|
|
*
|
|
|
|
* Failure: FAIL
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static herr_t
|
1999-04-16 03:57:50 +08:00
|
|
|
dump_all (hid_t group, const char *name, void UNUSED *op_data)
|
1998-08-20 05:46:55 +08:00
|
|
|
{
|
1998-10-29 14:27:31 +08:00
|
|
|
hid_t obj;
|
|
|
|
char *buf, *tmp;
|
|
|
|
H5G_stat_t statbuf;
|
|
|
|
int i;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
|
1998-09-03 05:16:24 +08:00
|
|
|
H5Gget_objinfo(group, name, FALSE, &statbuf);
|
1998-09-01 03:52:53 +08:00
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
tmp = (char *) malloc ((strlen(prefix)+strlen(name)+2) * sizeof(char));
|
|
|
|
strcpy(tmp, prefix);
|
1998-09-28 22:59:49 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
switch (statbuf.type) {
|
|
|
|
case H5G_LINK:
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
1998-09-01 03:52:53 +08:00
|
|
|
|
|
|
|
buf = malloc (statbuf.linklen*sizeof(char));
|
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->softlinkbegin, name, dump_header_format->softlinkblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-09-01 03:52:53 +08:00
|
|
|
if (H5Gget_linkval (group, name, statbuf.linklen, buf)>=0)
|
1998-10-29 14:27:31 +08:00
|
|
|
printf ("LINKTARGET \"%s\"\n", buf);
|
1998-09-28 22:59:49 +08:00
|
|
|
else {
|
|
|
|
printf ("h5dump error: unable to get link value.\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
1998-09-01 03:52:53 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend);
|
1998-09-01 03:52:53 +08:00
|
|
|
free (buf);
|
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
case H5G_GROUP:
|
|
|
|
if ((obj=H5Gopen (group, name))>=0) {
|
1998-10-29 14:27:31 +08:00
|
|
|
strcat(strcat(prefix,"/"), name);
|
1998-09-01 03:52:53 +08:00
|
|
|
dump_group (obj, name);
|
1998-10-29 14:27:31 +08:00
|
|
|
strcpy(prefix, tmp);
|
1998-09-01 03:52:53 +08:00
|
|
|
H5Gclose (obj);
|
1998-09-28 22:59:49 +08:00
|
|
|
} else {
|
|
|
|
printf ("h5dump error: unable to dump group %s\n",name);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
case H5G_DATASET:
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
if ((obj=H5Dopen (group, name))>=0) {
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
/* hard link */
|
|
|
|
H5Gget_objinfo(obj, ".", TRUE, &statbuf);
|
|
|
|
if (statbuf.nlink > 1) {
|
|
|
|
i = search_obj (dset_table, statbuf.objno);
|
|
|
|
if (i < 0) {
|
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-10-29 14:27:31 +08:00
|
|
|
printf("h5dump error: internal error\n");
|
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
goto done;
|
1999-10-30 03:50:25 +08:00
|
|
|
} else if (dset_table->objs[i].displayed) {
|
1998-10-29 14:27:31 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1999-10-30 03:50:25 +08:00
|
|
|
printf("%s \"%s\"\n", HARDLINK, dset_table->objs[i].objname);
|
1998-10-29 14:27:31 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
|
1998-10-29 14:27:31 +08:00
|
|
|
goto done;
|
|
|
|
} else {
|
1999-10-30 03:50:25 +08:00
|
|
|
dset_table->objs[i].displayed = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
strcat(tmp,"/");
|
|
|
|
strcat(tmp,name);
|
1999-10-30 03:50:25 +08:00
|
|
|
strcpy(dset_table->objs[i].objname, tmp);
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
|
|
|
}
|
1998-09-01 03:52:53 +08:00
|
|
|
dump_dataset (obj, name);
|
|
|
|
H5Dclose (obj);
|
1998-09-28 22:59:49 +08:00
|
|
|
} else {
|
|
|
|
printf ("h5dump error: unable to dump dataset %s\n",name);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
case H5G_TYPE:
|
1999-12-10 22:38:40 +08:00
|
|
|
if ((obj=H5Topen (group, name)) >= 0) {
|
|
|
|
dump_named_datatype (obj, name);
|
|
|
|
H5Tclose(obj);
|
|
|
|
} else {
|
|
|
|
printf ("h5dump error: unable to dump data type %s\n",name);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1999-12-10 22:38:40 +08:00
|
|
|
}
|
|
|
|
break;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-01 03:52:53 +08:00
|
|
|
default:
|
1998-10-29 14:27:31 +08:00
|
|
|
printf ("h5dump error: unknown object %s\n", name);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-01 03:52:53 +08:00
|
|
|
return FAIL;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
done:
|
|
|
|
free(tmp);
|
1998-08-20 05:46:55 +08:00
|
|
|
return SUCCEED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_named_datatype
|
|
|
|
*
|
|
|
|
* Purpose: Dump named data type
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
1998-09-01 03:52:53 +08:00
|
|
|
* Modifications: Comments: not yet implemented.
|
1998-08-20 05:46:55 +08:00
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
1998-10-29 14:27:31 +08:00
|
|
|
dump_named_datatype (hid_t type, const char *name) {
|
1999-12-18 03:06:39 +08:00
|
|
|
int nmembers = 1, x,j;
|
|
|
|
hid_t comptype;
|
|
|
|
char *compname;
|
|
|
|
int ndims, perm[H5DUMP_MAX_RANK];
|
1999-12-18 00:56:10 +08:00
|
|
|
size_t dims[H5DUMP_MAX_RANK];
|
2000-03-10 01:53:48 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->datatypebegin, name, dump_header_format->datatypeblockbegin);
|
1999-12-18 00:56:10 +08:00
|
|
|
|
1999-12-18 03:06:39 +08:00
|
|
|
if (H5Tget_class(type) == H5T_COMPOUND){
|
|
|
|
nmembers = H5Tget_nmembers(type);
|
|
|
|
for (x = 0; x < nmembers; x++){
|
|
|
|
comptype = H5Tget_member_type(type,x);
|
|
|
|
compname = H5Tget_member_name(type,x);
|
|
|
|
ndims = H5Tget_member_dims(type, x, dims, perm);
|
|
|
|
indentation (indent+COL);
|
|
|
|
print_datatype(comptype);
|
|
|
|
printf(" \"%s\"",compname);
|
|
|
|
if (ndims != 1 || dims[0] != 1) {
|
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
printf("[%d]",(int)dims[j]);
|
|
|
|
}
|
|
|
|
printf(";\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
indentation (indent+COL);
|
|
|
|
print_datatype(type);
|
|
|
|
printf(";\n");
|
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend);
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_group
|
|
|
|
*
|
|
|
|
* Purpose: Dump everything within the specified group
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
dump_group (hid_t gid, const char *name) {
|
1998-09-28 22:59:49 +08:00
|
|
|
H5G_stat_t statbuf;
|
1998-10-29 14:27:31 +08:00
|
|
|
hid_t dset, type;
|
|
|
|
char typename[1024], *tmp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
tmp = (char *) malloc ((strlen(prefix)+strlen(name)+2) * sizeof(char));
|
|
|
|
strcpy(tmp, prefix);
|
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->groupbegin, name, dump_header_format->groupblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indent += COL;
|
1999-10-02 05:56:00 +08:00
|
|
|
if (display_oid) {
|
|
|
|
dump_oid(gid);
|
|
|
|
}
|
1998-10-29 14:27:31 +08:00
|
|
|
if (!strcmp(name,"/") && unamedtype) { /* dump unamed type in root group */
|
1999-10-30 03:50:25 +08:00
|
|
|
for (i = 0; i < type_table->nobjs; i++)
|
|
|
|
if (!type_table->objs[i].recorded) {
|
|
|
|
dset = H5Dopen (gid, type_table->objs[i].objname);
|
1998-10-29 14:27:31 +08:00
|
|
|
type = H5Dget_type (dset);
|
1999-10-30 03:50:25 +08:00
|
|
|
sprintf(typename,"#%lu:%lu", type_table->objs[i].objno[0],
|
|
|
|
type_table->objs[i].objno[1]);
|
1998-10-29 14:27:31 +08:00
|
|
|
dump_named_datatype (type, typename);
|
|
|
|
H5Tclose(type);
|
|
|
|
H5Dclose(dset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
H5Gget_objinfo(gid, ".", TRUE, &statbuf);
|
|
|
|
if (statbuf.nlink > 1) {
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
i = search_obj (group_table, statbuf.objno);
|
|
|
|
if (i < 0) {
|
|
|
|
|
|
|
|
indentation (indent);
|
|
|
|
printf("h5dump error: internal error\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
} else if (group_table->objs[i].displayed) {
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
indentation (indent);
|
1999-10-30 03:50:25 +08:00
|
|
|
printf("%s \"%s\"\n",HARDLINK, group_table->objs[i].objname);
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
strcpy(group_table->objs[i].objname, prefix);
|
|
|
|
group_table->objs[i].displayed = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
H5Aiterate (gid, NULL, dump_attr, NULL);
|
|
|
|
H5Giterate (gid, ".", NULL, dump_all, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
H5Aiterate (gid, NULL, dump_attr, NULL);
|
|
|
|
H5Giterate (gid, ".", NULL, dump_all, NULL);
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indent -= COL;
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
free(tmp);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_dataset
|
|
|
|
*
|
|
|
|
* Purpose: Dump the specified data set
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
dump_dataset (hid_t did, const char *name) {
|
|
|
|
hid_t type, space;
|
|
|
|
|
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->datasetbegin, name, dump_header_format->datasetblockbegin);
|
1998-09-28 22:59:49 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
type = H5Dget_type (did);
|
|
|
|
space = H5Dget_space (did);
|
|
|
|
dump_datatype(type);
|
1998-09-01 03:52:53 +08:00
|
|
|
dump_dataspace(space);
|
1999-09-18 01:20:13 +08:00
|
|
|
if (display_oid){
|
|
|
|
dump_oid(did);
|
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
if (display_data)
|
1998-08-20 05:46:55 +08:00
|
|
|
switch (H5Tget_class(type)) {
|
|
|
|
case H5T_INTEGER:
|
|
|
|
dump_data(did, DATASET_DATA);
|
|
|
|
break;
|
|
|
|
case H5T_FLOAT:
|
|
|
|
dump_data(did, DATASET_DATA);
|
|
|
|
break;
|
|
|
|
case H5T_TIME:
|
1999-05-13 23:18:12 +08:00
|
|
|
indent += COL;
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
1999-05-13 23:18:12 +08:00
|
|
|
indent -= COL;
|
1998-08-20 05:46:55 +08:00
|
|
|
printf("DATA{ not yet implemented.}\n");
|
|
|
|
break;
|
|
|
|
case H5T_STRING:
|
1999-02-01 16:46:29 +08:00
|
|
|
dump_data(did, DATASET_DATA);
|
1998-08-20 05:46:55 +08:00
|
|
|
break;
|
|
|
|
case H5T_BITFIELD:
|
2000-06-01 00:08:10 +08:00
|
|
|
dump_data(did, DATASET_DATA);
|
1998-08-20 05:46:55 +08:00
|
|
|
break;
|
|
|
|
case H5T_OPAQUE:
|
2000-05-05 01:05:09 +08:00
|
|
|
/* indent += COL;
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-05-05 01:05:09 +08:00
|
|
|
indent -= COL;*/
|
|
|
|
dump_data(did, DATASET_DATA);
|
1998-08-20 05:46:55 +08:00
|
|
|
break;
|
|
|
|
case H5T_COMPOUND:
|
1998-10-29 14:27:31 +08:00
|
|
|
dump_data(did, DATASET_DATA);
|
1998-08-20 05:46:55 +08:00
|
|
|
break;
|
1999-06-10 02:43:07 +08:00
|
|
|
case H5T_REFERENCE:
|
|
|
|
dump_data(did, DATASET_DATA);
|
|
|
|
break;
|
1999-06-26 02:52:06 +08:00
|
|
|
case H5T_ENUM:
|
|
|
|
dump_data(did,DATASET_DATA);
|
1999-06-12 01:01:51 +08:00
|
|
|
break;
|
1999-06-26 02:52:06 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indent += COL;
|
1998-09-01 03:52:53 +08:00
|
|
|
H5Aiterate (did, NULL, dump_attr, NULL);
|
1999-05-13 23:18:12 +08:00
|
|
|
indent -= COL;
|
1998-09-01 03:52:53 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
H5Tclose(type);
|
|
|
|
H5Sclose(space);
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
#if H5DUMP_DEBUG
|
1998-10-29 14:27:31 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_tables
|
|
|
|
*
|
|
|
|
* Purpose: display the contents of tables for debugging purposes
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
1999-10-30 03:50:25 +08:00
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
static void
|
|
|
|
dump_tables(void) {
|
|
|
|
int i;
|
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
printf("group_table: # of entries = %d\n", group_table->nobjs);
|
|
|
|
for ( i = 0; i < group_table->nobjs; i++)
|
|
|
|
printf ("%ul %ul %s %d %d\n", group_table->objs[i].objno[0],
|
|
|
|
group_table->objs[i].objno[1],
|
|
|
|
group_table->objs[i].objname,
|
|
|
|
group_table->objs[i].displayed,
|
|
|
|
group_table->objs[i].recorded);
|
|
|
|
|
|
|
|
printf("\ndset_table: # of entries = %d\n", dset_table->nobjs);
|
|
|
|
for ( i = 0; i < dset_table->nobjs; i++)
|
|
|
|
printf ("%ul %ul %s %d %d\n", dset_table->objs[i].objno[0],
|
|
|
|
dset_table->objs[i].objno[1],
|
|
|
|
dset_table->objs[i].objname,
|
|
|
|
dset_table->objs[i].displayed,
|
|
|
|
dset_table->objs[i].recorded);
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
printf("\ntype_table: # of entries = %d\n", type_table->nobjs);
|
|
|
|
for ( i = 0; i < type_table->nobjs; i++)
|
|
|
|
printf ("%ul %ul %s %d %d\n", type_table->objs[i].objno[0],
|
|
|
|
type_table->objs[i].objno[1],
|
|
|
|
type_table->objs[i].objname,
|
|
|
|
type_table->objs[i].displayed,
|
|
|
|
type_table->objs[i].recorded);
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
#endif
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_data
|
|
|
|
*
|
|
|
|
* Purpose: Dump attribute or dataset data
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
2000-02-15 23:45:35 +08:00
|
|
|
*-----------------------------------------------------------------------
|
|
|
|
*/
|
1998-08-20 05:46:55 +08:00
|
|
|
static void
|
|
|
|
dump_data (hid_t obj_id, int obj_data) {
|
2000-03-10 01:53:48 +08:00
|
|
|
h5dump_t *outputformat = &dataformat;
|
2000-04-13 23:19:12 +08:00
|
|
|
int d_status = -1;
|
2000-02-15 23:45:35 +08:00
|
|
|
void *buf;
|
|
|
|
char *attr_name = malloc(sizeof(char)*80);
|
2000-02-25 01:01:50 +08:00
|
|
|
hid_t space, type, p_type;
|
2000-02-15 23:45:35 +08:00
|
|
|
int ndims, i;
|
|
|
|
hsize_t size[64], nelmts = 1;
|
|
|
|
int depth;
|
|
|
|
int stdindent = COL; /* should be 3*/
|
|
|
|
|
2000-02-18 02:35:30 +08:00
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
outputformat->line_ncols = nCols;
|
2000-02-18 02:35:30 +08:00
|
|
|
|
1999-05-13 23:18:12 +08:00
|
|
|
indent += COL;
|
2000-02-15 23:45:35 +08:00
|
|
|
/*the depth will tell us how far we need to indent extra. we use to just
|
|
|
|
use indent but with the merging of the tools lib we have to do something different
|
|
|
|
for the lib funtions... the normal indentation is 6 so when we dont need any extra
|
|
|
|
indentation, depth will be 0.*/
|
2000-04-20 02:08:11 +08:00
|
|
|
depth = indent/stdindent+1;
|
1998-08-20 05:46:55 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
/* printf("%s %s\n", dump_header_format->databegin, BEGIN);*/
|
|
|
|
begin_obj(dump_header_format->databegin, NULL, dump_header_format->datablockbegin);
|
2000-02-15 23:45:35 +08:00
|
|
|
|
1999-02-01 16:46:29 +08:00
|
|
|
/* Print all the values. */
|
2000-02-15 23:45:35 +08:00
|
|
|
if (obj_data == DATASET_DATA){
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = h5dump_dset(stdout, outputformat, obj_id, -1,depth);
|
2000-02-15 23:45:35 +08:00
|
|
|
}
|
|
|
|
else { /* need to call h5dump_mem for the attribute data */
|
|
|
|
|
|
|
|
type = H5Aget_type(obj_id);
|
|
|
|
/* if (type < 0) {
|
2000-04-13 23:19:12 +08:00
|
|
|
return (d_status);
|
2000-02-15 23:45:35 +08:00
|
|
|
}*/
|
|
|
|
p_type = h5dump_fixtype(type);
|
|
|
|
H5Tclose(type);
|
|
|
|
|
2000-04-13 23:19:12 +08:00
|
|
|
/* if (p_type < 0) return d_status;*/
|
2000-02-15 23:45:35 +08:00
|
|
|
|
|
|
|
space = H5Aget_space(obj_id);
|
|
|
|
|
2000-04-13 23:19:12 +08:00
|
|
|
/* if (space < 0) return d_status;
|
2000-02-15 23:45:35 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
ndims = H5Sget_simple_extent_dims(space, size, NULL);
|
|
|
|
for (i=0; i<ndims; i++) {
|
|
|
|
nelmts *= size[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buf = malloc(nelmts * MAX(H5Tget_size(type), H5Tget_size(p_type)));
|
|
|
|
assert(buf);
|
|
|
|
if (H5Aread(obj_id, p_type, buf)>=0) {
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = h5dump_mem(stdout, outputformat, p_type, space, buf, depth);
|
2000-02-15 23:45:35 +08:00
|
|
|
}
|
|
|
|
free(buf);
|
|
|
|
H5Tclose(p_type);
|
|
|
|
H5Sclose(space);
|
|
|
|
H5Tclose(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-13 23:19:12 +08:00
|
|
|
if (d_status < 0) {
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation(indent+COL);
|
1998-10-29 14:27:31 +08:00
|
|
|
printf("Unable to print data.\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
1998-10-29 14:27:31 +08:00
|
|
|
indentation(indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
/* printf("%s\n", END);*/
|
|
|
|
end_obj(dump_header_format->dataend, dump_header_format->datablockend);
|
1999-05-13 23:18:12 +08:00
|
|
|
indent -= COL;
|
1998-08-20 05:46:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
|
|
|
|
|
1998-08-20 05:46:55 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
1998-10-29 14:27:31 +08:00
|
|
|
* Function: main
|
1998-08-20 05:46:55 +08:00
|
|
|
*
|
|
|
|
* Purpose: HDF5 dumper
|
|
|
|
*
|
|
|
|
* Return: Success: 0
|
|
|
|
* Failure: 1
|
|
|
|
*
|
|
|
|
* Programmer: Ruey-Hsia Li
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
int
|
1999-10-16 03:04:01 +08:00
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
hid_t fid, gid, dsetid, typeid;
|
|
|
|
hid_t plist=H5P_DEFAULT;
|
|
|
|
const char *fname = NULL;
|
|
|
|
int i, index, curr_arg, display_bb=0, display_all=1, newwidth= 0;
|
|
|
|
int nopts=0, *opts;
|
|
|
|
char *buf, name[128], name1[128];
|
|
|
|
H5G_stat_t statbuf;
|
|
|
|
void *edata;
|
|
|
|
hid_t (*func)(void*);
|
1999-10-30 03:50:25 +08:00
|
|
|
find_objs_t *info = malloc(sizeof(find_objs_t));
|
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
dump_header_format = &standardformat;
|
1999-10-16 03:04:01 +08:00
|
|
|
|
|
|
|
/* Disable error reporting */
|
|
|
|
H5Eget_auto (&func, &edata);
|
|
|
|
H5Eset_auto (NULL, NULL);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
if (argc < 2 ) {
|
1998-08-20 05:46:55 +08:00
|
|
|
usage();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
opts = malloc((argc/2) * sizeof (int));
|
|
|
|
opts[0] = -1;
|
|
|
|
/* parse command line options */
|
|
|
|
for (curr_arg = 1; curr_arg < argc; curr_arg++)
|
|
|
|
|
|
|
|
if (argv[curr_arg][0] == '-') {
|
|
|
|
|
|
|
|
opts[nopts++] = curr_arg;
|
|
|
|
|
|
|
|
if (!strcmp(argv[curr_arg],"-h")) {
|
|
|
|
usage();
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(0);
|
1999-12-11 04:44:04 +08:00
|
|
|
}
|
|
|
|
else if (!strcmp(argv[curr_arg],"-V")){
|
|
|
|
print_version("h5dump");
|
|
|
|
free(opts);
|
|
|
|
exit(0);
|
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
|
1999-12-11 04:44:04 +08:00
|
|
|
else if (!strcmp(argv[curr_arg],"-bb"))
|
1998-09-28 22:59:49 +08:00
|
|
|
|
|
|
|
display_bb = 1;
|
|
|
|
|
|
|
|
else if (!strcmp(argv[curr_arg],"-header"))
|
|
|
|
|
|
|
|
display_data=0;
|
|
|
|
|
1999-12-11 04:44:04 +08:00
|
|
|
else if (!strcmp(argv[curr_arg],"-v"))
|
1999-09-18 01:20:13 +08:00
|
|
|
|
1999-12-11 04:44:04 +08:00
|
|
|
display_oid = 1;
|
1999-09-18 01:20:13 +08:00
|
|
|
|
1999-12-11 04:44:04 +08:00
|
|
|
else if (!strcmp(argv[curr_arg],"-w")){
|
|
|
|
/*
|
|
|
|
this way we know which arg was the -w
|
|
|
|
we know it won't be 0 since curr_arg starts at 1
|
|
|
|
*/
|
|
|
|
newwidth = curr_arg;
|
|
|
|
}
|
2000-03-10 01:53:48 +08:00
|
|
|
else if (!strcmp(argv[curr_arg], "-xml")){
|
|
|
|
dump_header_format = &xmlformat;
|
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
else if (strcmp(argv[curr_arg],"-a") &&
|
|
|
|
strcmp(argv[curr_arg],"-d") &&
|
|
|
|
strcmp(argv[curr_arg],"-g") &&
|
1998-10-29 14:27:31 +08:00
|
|
|
strcmp(argv[curr_arg],"-l") &&
|
|
|
|
strcmp(argv[curr_arg],"-t")) {
|
1998-09-28 22:59:49 +08:00
|
|
|
|
|
|
|
fprintf(stderr, "h5dump error: illegal option %s \n",
|
|
|
|
argv[curr_arg]);
|
|
|
|
usage();
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(1);
|
|
|
|
} else display_all = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check names */
|
|
|
|
if (argc == 2) {
|
|
|
|
if (opts[0] == 1) { /* argv[1] is an option */
|
|
|
|
fprintf(stderr, "h5dump error: no <names> or no <file>\n");
|
|
|
|
usage();
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < nopts-1; i++) {
|
|
|
|
if (opts[i+1]-opts[i] == 1) {
|
|
|
|
if (strcmp(argv[opts[i]], "-bb") &&
|
1999-09-18 01:20:13 +08:00
|
|
|
strcmp(argv[opts[i]], "-header") &&
|
2000-03-10 03:16:19 +08:00
|
|
|
strcmp(argv[opts[i]], "-xml") &&
|
1999-09-18 01:20:13 +08:00
|
|
|
strcmp(argv[opts[i]], "-v")) {
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf(stderr,"h5dump error: no <names> after option %s\n",
|
|
|
|
argv[opts[i]]);
|
|
|
|
usage();
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (argc - opts[nopts-1] == 1) {
|
|
|
|
fprintf(stderr,"h5dump error: no <file>\n");
|
|
|
|
usage();
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if (argc - opts[nopts-1] == 2) {
|
|
|
|
if (strcmp(argv[opts[i]], "-bb") &&
|
1999-09-18 01:20:13 +08:00
|
|
|
strcmp(argv[opts[i]], "-header") &&
|
2000-03-10 01:53:48 +08:00
|
|
|
strcmp(argv[opts[i]], "-xml") &&
|
1999-09-18 01:20:13 +08:00
|
|
|
strcmp(argv[opts[i]], "-v")) {
|
|
|
|
fprintf (stderr, "h5dump error: no <file> or no <names> or no <number> after option %s\n", argv[opts[i]]);
|
1998-09-28 22:59:49 +08:00
|
|
|
usage();
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (argv[argc-1][0] == '\\') fname = &argv[argc-1][1];
|
|
|
|
else fname = argv[argc-1];
|
|
|
|
|
|
|
|
if ((fid = H5Fopen (fname, H5F_ACC_RDONLY, plist)) < 0) {
|
|
|
|
fprintf (stderr, "h5dump error: unable to open file %s \n", fname);
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
1998-09-28 22:59:49 +08:00
|
|
|
exit(1);
|
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
/* allocate and initialize internal data structure */
|
1999-11-03 01:11:37 +08:00
|
|
|
init_table(&group_table);
|
|
|
|
init_table(&type_table);
|
|
|
|
init_table(&dset_table);
|
1999-11-04 00:46:09 +08:00
|
|
|
init_prefix(&prefix, prefix_len);
|
1999-10-30 03:50:25 +08:00
|
|
|
|
|
|
|
/*init the find_objs_t*/
|
|
|
|
info->threshold = 0;
|
|
|
|
info->prefix_len = 1024;
|
|
|
|
info->prefix = malloc(sizeof(char)*info->prefix_len);
|
|
|
|
*(info->prefix) = '\0';
|
|
|
|
info->group_table = group_table;
|
|
|
|
info->type_table = type_table;
|
|
|
|
info->dset_table = dset_table;
|
2000-04-13 23:19:12 +08:00
|
|
|
info->status = d_status;
|
1999-10-30 03:50:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
/* find all shared objects */
|
1999-10-30 03:50:25 +08:00
|
|
|
H5Giterate (fid, "/", NULL, find_objs, (void*)info);
|
1998-10-29 14:27:31 +08:00
|
|
|
strcpy(prefix, "");
|
|
|
|
|
1998-12-22 06:45:01 +08:00
|
|
|
/* does there exist unamed committed data type */
|
1999-10-30 03:50:25 +08:00
|
|
|
for ( i = 0; i < type_table->nobjs; i++)
|
|
|
|
if (type_table->objs[i].recorded == 0) unamedtype = 1;
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
#ifdef H5DUMP_DEBUG
|
|
|
|
dump_tables();
|
|
|
|
#endif
|
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
|
|
|
|
if (info->status) {
|
1998-10-29 14:27:31 +08:00
|
|
|
printf("internal error! \n");
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
1998-12-22 06:45:01 +08:00
|
|
|
/* start to dump */
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->filebegin, fname, dump_header_format->fileblockbegin);
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1999-09-18 01:20:13 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
if (display_bb) dump_bb();
|
1999-09-18 01:20:13 +08:00
|
|
|
|
|
|
|
if (newwidth) {
|
|
|
|
sscanf(argv[newwidth + 1], "%d", &nCols);
|
|
|
|
}
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
if (display_all) {
|
|
|
|
|
|
|
|
if ((gid = H5Gopen (fid, "/")) < 0 ) {
|
|
|
|
fprintf(stdout, "h5dump error: unable to open root group\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
} else
|
1998-09-28 22:59:49 +08:00
|
|
|
dump_group(gid, "/");
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
if (H5Gclose (gid) < 0) {
|
|
|
|
fprintf(stdout, "h5dump error: unable to close root group\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
for (i = 0; i < nopts; i++) {
|
|
|
|
if (!strcmp(argv[opts[i]],"-a")) {
|
|
|
|
|
|
|
|
for (curr_arg = opts[i]+1;
|
|
|
|
curr_arg < ((i+1)==nopts?(argc-1):opts[i+1]);
|
|
|
|
curr_arg++)
|
|
|
|
dump_selected_attr (fid, argv[curr_arg]);
|
|
|
|
|
|
|
|
} else if (!strcmp(argv[opts[i]],"-d")) {
|
|
|
|
for (curr_arg = opts[i]+1;
|
|
|
|
curr_arg < ((i+1)==nopts?(argc-1):opts[i+1]);
|
|
|
|
curr_arg++) {
|
|
|
|
|
|
|
|
if ((dsetid = H5Dopen (fid, argv[curr_arg]))<0) {
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj (dump_header_format->datasetbegin, argv[curr_arg], dump_header_format->datasetblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n",
|
|
|
|
argv[curr_arg]);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
} else {
|
1998-10-29 14:27:31 +08:00
|
|
|
H5Gget_objinfo(dsetid, ".", TRUE, &statbuf);
|
|
|
|
if (statbuf.nlink > 1) {
|
|
|
|
index = search_obj (dset_table, statbuf.objno);
|
|
|
|
if (index >= 0) {
|
1999-10-30 03:50:25 +08:00
|
|
|
if (dset_table->objs[index].displayed) {
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->datasetbegin, argv[curr_arg], dump_header_format->datasetblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (indent+COL);
|
1998-12-22 06:45:01 +08:00
|
|
|
printf("%s \"%s\"\n", HARDLINK,
|
1999-10-30 03:50:25 +08:00
|
|
|
dset_table->objs[index].objname);
|
1998-10-29 14:27:31 +08:00
|
|
|
indentation (indent);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend);
|
1998-10-29 14:27:31 +08:00
|
|
|
} else {
|
1999-10-30 03:50:25 +08:00
|
|
|
strcpy(dset_table->objs[index].objname, argv[curr_arg]);
|
|
|
|
dset_table->objs[index].displayed = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
dump_dataset(dsetid, argv[curr_arg]);
|
|
|
|
}
|
2000-04-13 23:19:12 +08:00
|
|
|
} else d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
} else
|
|
|
|
dump_dataset(dsetid, argv[curr_arg]);
|
2000-04-13 23:19:12 +08:00
|
|
|
if (H5Dclose(dsetid)<1) d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
|
|
|
|
|
1998-09-28 22:59:49 +08:00
|
|
|
} else if (!strcmp(argv[opts[i]],"-g")) {
|
|
|
|
|
|
|
|
for (curr_arg = opts[i]+1;
|
|
|
|
curr_arg < ((i+1)==nopts?(argc-1):opts[i+1]);
|
|
|
|
curr_arg++) {
|
|
|
|
if ((gid = H5Gopen (fid, argv[curr_arg])) < 0) {
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj (dump_header_format->groupbegin, argv[curr_arg], dump_header_format->groupblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n",
|
|
|
|
argv[curr_arg]);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->groupend, dump_header_format->groupblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
} else {
|
1998-10-29 14:27:31 +08:00
|
|
|
H5Gget_objinfo(gid, ".", TRUE, &statbuf);
|
|
|
|
strcpy(prefix, argv[curr_arg]);
|
1998-09-28 22:59:49 +08:00
|
|
|
dump_group(gid, argv[curr_arg]);
|
2000-04-13 23:19:12 +08:00
|
|
|
if (H5Gclose (gid) < 0) d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (!strcmp(argv[opts[i]],"-l")) {
|
|
|
|
|
|
|
|
for (curr_arg = opts[i]+1;
|
|
|
|
curr_arg < ((i+1)==nopts?(argc-1):opts[i+1]);
|
|
|
|
curr_arg++) {
|
|
|
|
|
|
|
|
|
|
|
|
if (H5Gget_objinfo(fid, argv[curr_arg], FALSE, &statbuf) < 0) {
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->softlinkbegin, argv[curr_arg], dump_header_format->softlinkblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf(stdout, "h5dump error: unable to get obj info from %s\n", argv[curr_arg]);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
|
|
|
|
} else if (statbuf.type == H5G_LINK) {
|
|
|
|
|
|
|
|
buf = malloc(statbuf.linklen*sizeof(char));
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->softlinkbegin, argv[curr_arg], dump_header_format->softlinkblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
if (H5Gget_linkval (fid, argv[curr_arg], statbuf.linklen, buf)>=0)
|
1998-10-29 14:27:31 +08:00
|
|
|
printf ("LINKTARGET \"%s\"\n", buf);
|
1998-09-28 22:59:49 +08:00
|
|
|
else {
|
|
|
|
fprintf (stdout, "h5dump error: unable to get link value\n");
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend);
|
1998-09-28 22:59:49 +08:00
|
|
|
free(buf);
|
|
|
|
|
|
|
|
} else {
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj(dump_header_format->softlinkbegin, argv[curr_arg], dump_header_format->softlinkblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-09-28 22:59:49 +08:00
|
|
|
fprintf(stdout, "h5dump error: %s is not a link\n", argv[curr_arg]);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->softlinkend, dump_header_format->softlinkblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
} else if (!strcmp(argv[opts[i]],"-t")) {
|
|
|
|
|
|
|
|
|
|
|
|
for (curr_arg = opts[i]+1;
|
|
|
|
curr_arg < ((i+1)==nopts?(argc-1):opts[i+1]);
|
|
|
|
curr_arg++) {
|
|
|
|
|
|
|
|
if ((typeid=H5Topen (fid, argv[curr_arg])) < 0) {
|
|
|
|
|
|
|
|
/* check if argv[curr_arg] is unamed data type */
|
|
|
|
index = 0;
|
1999-10-30 03:50:25 +08:00
|
|
|
while (index < type_table->nobjs ) {
|
|
|
|
if (!type_table->objs[index].recorded) { /* unamed data type */
|
|
|
|
sprintf(name,"#%lu:%lu\n", type_table->objs[index].objno[0],
|
|
|
|
type_table->objs[index].objno[1]);
|
|
|
|
sprintf(name1,"/#%lu:%lu\n", type_table->objs[index].objno[0],
|
|
|
|
type_table->objs[index].objno[1]);
|
1998-10-29 14:27:31 +08:00
|
|
|
if (!strncmp(name, argv[curr_arg], strlen(argv[curr_arg])) ||
|
|
|
|
!strncmp(name1, argv[curr_arg], strlen(argv[curr_arg]))) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
index++;
|
|
|
|
}
|
1999-10-30 03:50:25 +08:00
|
|
|
if (index == type_table->nobjs) { /* unknown type */
|
2000-03-10 01:53:48 +08:00
|
|
|
begin_obj (dump_header_format->datatypebegin, argv[curr_arg], dump_header_format->datatypeblockbegin);
|
1999-05-13 23:18:12 +08:00
|
|
|
indentation (COL);
|
1998-10-29 14:27:31 +08:00
|
|
|
fprintf (stdout, "h5dump error: unable to open %s\n",
|
|
|
|
argv[curr_arg]);
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->datatypeend, dump_header_format->datatypeblockend);
|
2000-04-13 23:19:12 +08:00
|
|
|
d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
} else {
|
1999-10-30 03:50:25 +08:00
|
|
|
dsetid = H5Dopen (fid, type_table->objs[index].objname) ;
|
1998-10-29 14:27:31 +08:00
|
|
|
typeid = H5Dget_type (dsetid);
|
|
|
|
dump_named_datatype (typeid, argv[curr_arg]);
|
|
|
|
H5Tclose(typeid);
|
|
|
|
H5Dclose(dsetid);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
dump_named_datatype (typeid, argv[curr_arg]);
|
2000-04-13 23:19:12 +08:00
|
|
|
if (H5Tclose(typeid) < 0) d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
}
|
|
|
|
}
|
1999-09-18 01:20:13 +08:00
|
|
|
}
|
1998-09-28 22:59:49 +08:00
|
|
|
}
|
1998-08-20 05:46:55 +08:00
|
|
|
|
2000-03-10 01:53:48 +08:00
|
|
|
end_obj(dump_header_format->fileend, dump_header_format->fileblockend);
|
1998-09-28 22:59:49 +08:00
|
|
|
|
1998-10-29 14:27:31 +08:00
|
|
|
done:
|
1998-08-20 05:46:55 +08:00
|
|
|
|
1998-10-01 06:01:13 +08:00
|
|
|
H5Eset_auto (func, edata);
|
1998-10-29 14:27:31 +08:00
|
|
|
free(opts);
|
2000-04-13 23:19:12 +08:00
|
|
|
if (H5Fclose (fid) < 0) d_status = 1;
|
1998-10-29 14:27:31 +08:00
|
|
|
|
1999-10-30 03:50:25 +08:00
|
|
|
free (group_table->objs);
|
|
|
|
free (dset_table->objs);
|
|
|
|
free (type_table->objs);
|
1998-10-29 14:27:31 +08:00
|
|
|
free (prefix);
|
1999-10-30 03:50:25 +08:00
|
|
|
free (info->prefix);
|
|
|
|
free (info);
|
2000-04-13 23:19:12 +08:00
|
|
|
return d_status;
|
1998-08-20 05:46:55 +08:00
|
|
|
|
|
|
|
}
|
1999-06-14 10:40:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: print_enum
|
|
|
|
*
|
|
|
|
* Purpose: prints the enum data -
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Patrick Lu
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
* NOTE: this function was taken from h5ls. should be moved into the toolslib
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void print_enum(hid_t type){
|
|
|
|
char **name=NULL; /*member names */
|
|
|
|
unsigned char *value=NULL; /*value array */
|
|
|
|
int nmembs; /*number of members */
|
|
|
|
int nchars; /*number of output characters */
|
|
|
|
hid_t super; /*enum base integer type */
|
|
|
|
hid_t native=-1; /*native integer data type */
|
|
|
|
size_t dst_size; /*destination value type size */
|
|
|
|
int i; /*miscellaneous counters */
|
|
|
|
size_t j;
|
|
|
|
|
|
|
|
nmembs = H5Tget_nmembers(type);
|
|
|
|
super = H5Tget_super(type);
|
|
|
|
/*
|
|
|
|
* Determine what data type to use for the native values. To simplify
|
|
|
|
* things we entertain three possibilities:
|
|
|
|
* 1. long_long -- the largest native signed integer
|
|
|
|
* 2. unsigned long_long -- the largest native unsigned integer
|
|
|
|
* 3. raw format
|
|
|
|
*/
|
|
|
|
if (H5Tget_size(type)<=sizeof(long_long)) {
|
|
|
|
dst_size = sizeof(long_long);
|
|
|
|
if (H5T_SGN_NONE==H5Tget_sign(type)) {
|
|
|
|
native = H5T_NATIVE_ULLONG;
|
|
|
|
} else {
|
|
|
|
native = H5T_NATIVE_LLONG;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dst_size = H5Tget_size(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the names and raw values of all members */
|
|
|
|
name = calloc(nmembs, sizeof(char*));
|
|
|
|
value = calloc(nmembs, MAX(H5Tget_size(type), dst_size));
|
|
|
|
for (i=0; i<nmembs; i++) {
|
|
|
|
name[i] = H5Tget_member_name(type, i);
|
|
|
|
H5Tget_member_value(type, i, value+i*H5Tget_size(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert values to native data type */
|
1999-07-03 18:34:45 +08:00
|
|
|
if (native>0) H5Tconvert(super, native, nmembs, value, NULL, H5P_DEFAULT);
|
1999-06-14 10:40:52 +08:00
|
|
|
|
|
|
|
/* Sort members by increasing value */
|
|
|
|
/*not implemented yet*/
|
|
|
|
|
|
|
|
/* Print members */
|
|
|
|
for (i=0; i<nmembs; i++) {
|
|
|
|
printf("\n%*s", indent+4, "");
|
|
|
|
nchars = printf("\"%s\"",name[i]);/*display_string(stdout, name[i], TRUE);*/
|
|
|
|
printf("%*s ", MAX(0, 16-nchars), "");
|
|
|
|
|
|
|
|
if (native<0) {
|
|
|
|
printf("0x");
|
|
|
|
for (j=0; j<dst_size; j++) {
|
|
|
|
printf("%02x", value[i*dst_size+j]);
|
|
|
|
}
|
|
|
|
} else if (H5T_SGN_NONE==H5Tget_sign(native)) {
|
|
|
|
printf("%"PRINTF_LL_WIDTH"u",
|
1999-09-30 00:54:00 +08:00
|
|
|
*((unsigned long_long*)((void*)(value+i*dst_size))));
|
1999-06-14 10:40:52 +08:00
|
|
|
} else {
|
|
|
|
printf("%"PRINTF_LL_WIDTH"d",
|
1999-09-30 00:54:00 +08:00
|
|
|
*((long_long*)((void*)(value+i*dst_size))));
|
1999-06-14 10:40:52 +08:00
|
|
|
}
|
1999-06-23 03:10:18 +08:00
|
|
|
printf(";");
|
1999-06-14 10:40:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Release resources */
|
|
|
|
for (i=0; i<nmembs; i++) free(name[i]);
|
|
|
|
free(name);
|
|
|
|
free(value);
|
|
|
|
H5Tclose(super);
|
|
|
|
|
|
|
|
if (0==nmembs) printf("\n%*s <empty>", indent+4, "");
|
|
|
|
/* printf("\n%*s}", indent, "");*/
|
|
|
|
/* return TRUE;*/
|
|
|
|
}
|
|
|
|
|
1999-09-18 01:20:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: dump_oid
|
|
|
|
*
|
|
|
|
* Purpose: Prints the object ids
|
|
|
|
*
|
|
|
|
* Return: void
|
|
|
|
*
|
|
|
|
* Programmer: Patrick Lu
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
dump_oid(hid_t oid){
|
1999-10-02 05:56:00 +08:00
|
|
|
|
|
|
|
|
1999-09-18 01:20:13 +08:00
|
|
|
indent += COL;
|
|
|
|
indentation (indent);
|
1999-06-14 10:40:52 +08:00
|
|
|
|
1999-10-13 23:11:02 +08:00
|
|
|
printf ("%s %s ", OBJID, BEGIN);
|
1999-09-18 01:20:13 +08:00
|
|
|
printf("%d", oid);
|
|
|
|
printf (" %s\n", END);
|
|
|
|
indent -= COL;
|
1999-09-30 00:54:00 +08:00
|
|
|
}
|