diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-11-05 20:28:34 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-11-05 20:28:34 (GMT) |
commit | 46f683cf14957d39550e826e374e1f3f5a64958c (patch) | |
tree | bbba7b3c43ed2b4af88b78dd8d06636919d5effc /tools | |
parent | b7d05e45c85d44810ca1f63485329002feb14640 (diff) | |
download | hdf5-46f683cf14957d39550e826e374e1f3f5a64958c.zip hdf5-46f683cf14957d39550e826e374e1f3f5a64958c.tar.gz hdf5-46f683cf14957d39550e826e374e1f3f5a64958c.tar.bz2 |
[svn-r876] Changes since 19981102
----------------------
./bin/snapshot
Made same fix as for the release script yesterday.
./src/H5D.c
./src/H5Dprivate.h
./src/H5G.c
./src/H5Gprivate.h
./src/H5Gpublic.h
./src/H5O.c
./src/H5Oprivate.h
./src/H5RA.c
./src/H5RAprivate.h
./src/H5T.c
./src/H5Tprivate.h
Improved object type checking. Instead of determining the
object type by trying to open each of the possible types, we
keep a table of associations between object type number (like
H5G_GROUP, H5G_DATASET, H5D_TYPE, and H5D_RAGGED) and an `isa'
function that returns true if the object header has the right
messages to make the object a particular type. This mechanism
also allows specialization of object types by permitting an
object to satisfy more than one `isa' function.
Added `isa' functions for groups, datasets, ragged arrays, and
committed data types.
./src/H5config.h.in
Added HAVE_STAT_ST_BLOCKS. I thought this had already been
added, but apparently not.
./tools/h5ls.c
Removed system include files since they're already included by
H5private.h and since I wasn't including them portably anyway.
By default, 1-byte integer types are printed as integer values
instead of ASCII characters. However, the `-s' or `--string'
command-line switch causes the data to be interpretted as
ASCII. String data types are always printed as character
data.
Ragged arrays are now identified as ragged arrays and h5ls
doesn't descend into the group automatically. This uses the
new object type specialization stuff.
./tools/h5tools.c
./tools/h5tools.h
Added the ability to print 1-byte integer types as either
ASCII or numeric data instead of always ASCII. The default is
to print as numeric data.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5ls.c | 66 | ||||
-rw-r--r-- | tools/h5tools.c | 15 | ||||
-rw-r--r-- | tools/h5tools.h | 8 |
3 files changed, 71 insertions, 18 deletions
diff --git a/tools/h5ls.c b/tools/h5ls.c index 39124b8..3d7b845 100644 --- a/tools/h5ls.c +++ b/tools/h5ls.c @@ -5,14 +5,15 @@ * Programmer: Robb Matzke <matzke@llnl.gov> * Monday, March 23, 1998 */ -#include <ctype.h> -#include <h5tools.h> -#include <hdf5.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> + +/* + * We include the private header file so we can get to the uniform + * programming environment it declares. + */ #include <H5private.h> +#include <h5tools.h> + #ifndef HAVE_ATTRIBUTE # undef __attribute__ # define __attribute__(X) /*void*/ @@ -25,6 +26,7 @@ static int verbose_g = 0; static int dump_g = 0; static int width_g = 80; +static int string_g = FALSE; /* Information about how to display each type of object */ static struct dispatch_t { @@ -68,6 +70,7 @@ usage: %s [OPTIONS] FILE [OBJECTS...]\n\ OPTIONS\n\ -h, -?, --help Print a usage message and exit\n\ -d, --dump Print the values of datasets\n\ + -s, --string Print 1-byte integer datasets as ASCII\n\ -wN, --width=N Set the number of columns of output\n\ -v, --verbose Generate more verbose output\n\ -V, --version Print version number and exit\n\ @@ -112,9 +115,11 @@ dump_dataset_values(hid_t dset) /* * If the dataset is a 1-byte integer type then format it as an ASCI - * character string instead of integers. + * character string instead of integers if the `-s' or `--string' + * command-line option was given. */ - if (1==size && H5T_INTEGER==H5Tget_class(f_type)) { + if (string_g && 1==size && H5T_INTEGER==H5Tget_class(f_type)) { + info.ascii = TRUE; info.elmt_suf1 = ""; info.elmt_suf2 = ""; info.idx_fmt = " (%s) \""; @@ -286,6 +291,34 @@ dataset_list2(hid_t dset) /*------------------------------------------------------------------------- + * Function: ragged_list2 + * + * Purpose: List information about a ragged array which should appear + * after information which is general to all objects. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Robb Matzke + * Thursday, November 5, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +ragged_list2(hid_t __unused__ ra) +{ + if (dump_g) { + puts(" Data: Not implemented yet (see values of member"); + puts(" datasets `raw', `over', and `meta')"); + } + return -1; +} + + +/*------------------------------------------------------------------------- * Function: link_open * * Purpose: This gets called to open a symbolic link. Since symbolic @@ -399,7 +432,6 @@ list (hid_t group, const char *name, void __unused__ *cd) return 0; } - /*------------------------------------------------------------------------- * Function: main @@ -426,6 +458,7 @@ main (int argc, char *argv[]) const char *s; char *rest; int argno; + H5G_stat_t sb; DISPATCH(H5G_DATASET, "Dataset", H5Dopen, H5Dclose, dataset_list1, dataset_list2); @@ -435,6 +468,8 @@ main (int argc, char *argv[]) NULL, NULL); DISPATCH(H5G_LINK, "-> ", link_open, NULL, NULL, NULL); + DISPATCH(H5G_RAGGED, "Ragged Array", H5Gopen, H5Gclose, + NULL, ragged_list2); /* Name of this program without the path */ if ((progname=strrchr (argv[0], '/'))) progname++; @@ -451,6 +486,8 @@ main (int argc, char *argv[]) exit(0); } else if (!strcmp(argv[argno], "--dump")) { dump_g++; + } else if (!strcmp(argv[argno], "--string")) { + string_g = TRUE; } else if (!strncmp(argv[argno], "--width=", 8)) { width_g = strtol(argv[argno]+8, &rest, 0); if (width_g<=0 || *rest) { @@ -488,6 +525,9 @@ main (int argc, char *argv[]) case 'd': /* --dump */ dump_g++; break; + case 's': + string_g = TRUE; + break; case 'v': /* --verbose */ verbose_g++; break; @@ -531,17 +571,15 @@ main (int argc, char *argv[]) H5Giterate(file, "/", NULL, list, NULL); } else { for (/*void*/; argno<argc; argno++) { - H5E_BEGIN_TRY { - root = H5Gopen (file, argv[argno]); - } H5E_END_TRY; - if (root>=0) { + if (H5Gget_objinfo(file, argv[argno], TRUE, &sb)>=0 && + H5G_GROUP==sb.type) { H5Giterate(file, argv[argno], NULL, list, NULL); } else if ((root=H5Gopen(file, "/"))<0) { exit(1); } else { list(root, argv[argno], NULL); + if (H5Gclose(root)<0) exit(1); } - if (H5Gclose(root)<0) exit(1); } } diff --git a/tools/h5tools.c b/tools/h5tools.c index d3c9615..83915b3 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -22,7 +22,7 @@ * size of that temporary buffer in bytes. For efficiency's sake, choose the * largest value suitable for your machine (for testing use a small value). */ -#if 0 +#if 1 #define H5DUMP_BUFSIZE (1024*1024) #else #define H5DUMP_BUFSIZE (1024) @@ -126,8 +126,9 @@ h5dump_sprint(char *s/*out*/, const h5dump_t *info, hid_t type, void *vp) } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { sprintf(temp, "%g", *((float*)vp)); - } else if (H5Tequal(type, H5T_NATIVE_CHAR) || - H5Tequal(type, H5T_NATIVE_UCHAR)) { + } else if (info->ascii && + (H5Tequal(type, H5T_NATIVE_CHAR) || + H5Tequal(type, H5T_NATIVE_UCHAR))) { switch (*((char*)vp)) { case '"': strcpy(temp, "\\\""); @@ -223,7 +224,13 @@ h5dump_sprint(char *s/*out*/, const h5dump_t *info, hid_t type, void *vp) } } if (quote) sprintf(temp+strlen(temp), "%c", quote); - + + } else if (H5Tequal(type, H5T_NATIVE_CHAR)) { + sprintf(temp, "%d", *((signed char*)vp)); + + } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { + sprintf(temp, "%u", *((unsigned char*)vp)); + } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { sprintf(temp, "%d", *((short*)vp)); diff --git a/tools/h5tools.h b/tools/h5tools.h index 374bb71..54017aa 100644 --- a/tools/h5tools.h +++ b/tools/h5tools.h @@ -58,6 +58,13 @@ typedef struct h5dump_t { /* * Fields associated with the individual elements. * + * ascii: If set then print 1-byte integer values as an ASCII + * character (no quotes). If the character is one of the + * standard C escapes then print the escaped version. If + * the character is unprintable then print a 3-digit octal + * escape. If `ascii' is zero then then 1-byte integers are + * printed as numeric values. The default is zero. + * * fmt: A printf(3c) format to use to print the value string * after it has been rendered. The default is "%s". * @@ -69,6 +76,7 @@ typedef struct h5dump_t { * are followed on the same line by another element. The * default is a single space. */ + int ascii; const char *elmt_fmt; const char *elmt_suf1; const char *elmt_suf2; |