summaryrefslogtreecommitdiffstats
path: root/tools/h5ls.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-11-05 20:28:34 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-11-05 20:28:34 (GMT)
commit46f683cf14957d39550e826e374e1f3f5a64958c (patch)
treebbba7b3c43ed2b4af88b78dd8d06636919d5effc /tools/h5ls.c
parentb7d05e45c85d44810ca1f63485329002feb14640 (diff)
downloadhdf5-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/h5ls.c')
-rw-r--r--tools/h5ls.c66
1 files changed, 52 insertions, 14 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);
}
}