diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-07-24 14:28:32 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-07-24 14:28:32 (GMT) |
commit | 78c70d7be5430c106c53f5c067128518bc874d7d (patch) | |
tree | bf4445accf81ab4d6f218ade9712fd9a70d383af /tools/h5ls.c | |
parent | 181a423f85bf5febedd0d1b083e77f8b978d5b50 (diff) | |
download | hdf5-78c70d7be5430c106c53f5c067128518bc874d7d.zip hdf5-78c70d7be5430c106c53f5c067128518bc874d7d.tar.gz hdf5-78c70d7be5430c106c53f5c067128518bc874d7d.tar.bz2 |
[svn-r541] Changes since 19980723
----------------------
./tools/h5dump.c
./tools/h5ls.c
./tools/h5tools.h
Able to handle compound data types now. Moved code that
chooses memory data type based on file data type from h5ls to
libh5tools.a(h5dump.o)
Diffstat (limited to 'tools/h5ls.c')
-rw-r--r-- | tools/h5ls.c | 66 |
1 files changed, 15 insertions, 51 deletions
diff --git a/tools/h5ls.c b/tools/h5ls.c index 93a756a..0ae0c21 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -78,9 +78,9 @@ usage: %s [OPTIONS] FILE [GROUP]\n\ static void dump_dataset_values(hid_t dset) { - hid_t f_type, m_type=-1; + hid_t f_type = H5Dget_type(dset); + size_t size = H5Tget_size(f_type); h5dump_t info; - size_t size; /* Set to all default values and then override */ memset(&info, 0, sizeof info); @@ -88,62 +88,26 @@ dump_dataset_values(hid_t dset) info.line_ncols = width_g; /* - * Decide which data type to use for printing the values and make any - * necessary adjustments to the way the values will be formatted. + * If the dataset is a 1-byte integer type then format it as an ASCI + * character string instead of integers. */ - f_type = H5Dget_type(dset); - size = H5Tget_size(f_type); - switch (H5Tget_class(f_type)) { - case H5T_INTEGER: - if (1==size) { - /* - * Assume that the dataset is being used to hold character values - * and print the values as strings. - */ - info.elmt_suf1 = ""; - info.elmt_suf2 = ""; - info.idx_fmt = " (%s) \""; - info.line_suf = "\""; - } - - /* - * For printing use an integer which is the same width and sign as - * the file but in native byte order. - */ - m_type = H5Tcopy(H5T_NATIVE_INT); - H5Tset_offset(m_type, 0); - H5Tset_precision(m_type, size*8); - H5Tset_size(m_type, size); - H5Tset_sign(m_type, H5Tget_sign(f_type)); - break; - - case H5T_FLOAT: - if (size==sizeof(float)) { - m_type = H5Tcopy(H5T_NATIVE_FLOAT); - } else { - m_type = H5Tcopy(H5T_NATIVE_DOUBLE); - } - break; - - case H5T_COMPOUND: - printf(" Data: printing of compound data types is not implemented " - "yet\n"); - break; - - default: - /*unable to print*/ - printf(" Data: [unable to print]\n"); - break; + if (1==size && H5T_INTEGER==H5Tget_class(f_type)) { + info.elmt_suf1 = ""; + info.elmt_suf2 = ""; + info.idx_fmt = " (%s) \""; + info.line_suf = "\""; } - H5Tclose(f_type); - if (m_type<0) return; /*not printable*/ + /* * Print all the values. */ printf(" Data:\n"); - h5dump(stdout, &info, dset, m_type); - H5Tclose(m_type); + if (h5dump(stdout, &info, dset, -1)<0) { + printf(" Unable to print data.\n"); + } + + H5Tclose(f_type); } |