summaryrefslogtreecommitdiffstats
path: root/tools/h5ls.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1999-09-30 16:14:14 (GMT)
committerRobb Matzke <matzke@llnl.gov>1999-09-30 16:14:14 (GMT)
commitbdf0dbf7ed9a671cf915de65006ae5a5379c6941 (patch)
tree2117c72f7f589bd030d32dbc398c836e8a4524c8 /tools/h5ls.c
parent03d438979b7bc6a08d25d121676bbd2083254c80 (diff)
downloadhdf5-bdf0dbf7ed9a671cf915de65006ae5a5379c6941.zip
hdf5-bdf0dbf7ed9a671cf915de65006ae5a5379c6941.tar.gz
hdf5-bdf0dbf7ed9a671cf915de65006ae5a5379c6941.tar.bz2
[svn-r1697] Changes since 19990915
---------------------- ./src/H5public.h We undefine a bunch of things that could get redefined in the config file because some customers have applications that include headers from multiple packages, all of which might be using autoconf. Include <stdint.h> for the C9x types. ./test/h5test.h More flushing of stdout for when testing is redirected down a pipe. ./tools/h5ls.c Added a `-S' or `--simple' switch which causes the output to be simplified somewhat for easier parsing by other scripts. For instance, characters are escaped using a very simple mechanism instead of C's more complicated backslash notation, data doesn't have `{}' or `[]' characters interspersed for compound and array types, and data is printed with exactly one element per line. This switch is now used by an HDF5-to-HTML CGI script being developed for the DMF people. ./tools/h5tools.c ./tools/h5tools.h The repeat threshold which controls how strings are printed when a character repeats a bunch of times is now settable at runtime instead of compile time. The default is to show all characters, like "abceeeeeeeeeeeeeeeeeeeeeeeeeeeeeefgh" But if you set it to something like 5 then any sequence of 5 or more characters is replaced by something shorter, like: "abc" 'e'x30 "fgh" or Added an `str_locale' property which describes how to escape special characters in strings. The default is C-like escapes but an alternative is ESCAPE_HTML which replaces all non-alphanumeric characters with a 3-character HTML escape of the form `%XX' Fixed a bug where empty strings didn't even have the quote characters printed. Now empty strings show up as `""' instead of absolutely nothing. Added a `per_line' property which controls the maximum number of elements which will appear per line of output. The default is infinity but in practice the right margin causes line breaks. By setting the `per_line' value to one and the right margin to a very large value one can achieve output with exactly one element per line.
Diffstat (limited to 'tools/h5ls.c')
-rw-r--r--tools/h5ls.c61
1 files changed, 47 insertions, 14 deletions
diff --git a/tools/h5ls.c b/tools/h5ls.c
index 191445a..4d4d978 100644
--- a/tools/h5ls.c
+++ b/tools/h5ls.c
@@ -41,6 +41,7 @@ static hbool_t recursive_g = FALSE; /*recursive descent listing */
static hbool_t grp_literal_g = FALSE; /*list group, not contents */
static hbool_t hexdump_g = FALSE; /*show data as raw hexadecimal */
static hbool_t show_errors_g = FALSE; /*print HDF5 error messages */
+static hbool_t simple_output_g = FALSE; /*make output more machine-readable */
/* Info to pass to the iteration functions */
typedef struct iter_t {
@@ -108,6 +109,7 @@ usage: %s [OPTIONS] [OBJECTS...]\n\
-l, --label Label members of compound datasets\n\
-r, --recursive List all groups recursively, avoiding cycles\n\
-s, --string Print 1-byte integer datasets as ASCII\n\
+ -S, --simple Use a machine-readable output format\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\
@@ -1098,7 +1100,9 @@ display_type(hid_t type, int ind)
* Tuesday, July 21, 1998
*
* Modifications:
- *
+ * Robb Matzke, 1999-09-27
+ * Understands the simple_output_g switch which causes data to
+ * be displayed in a more machine-readable format.
*-------------------------------------------------------------------------
*/
static void
@@ -1107,21 +1111,41 @@ dump_dataset_values(hid_t dset)
hid_t f_type = H5Dget_type(dset);
size_t size = H5Tget_size(f_type);
h5dump_t info;
-
+ char string_prefix[64];
+
/* Set to all default values and then override */
memset(&info, 0, sizeof info);
- info.idx_fmt = "(%s)";
- info.line_ncols = width_g;
- info.line_multi_new = 1;
- if (label_g) info.cmpd_name = "%s=";
-
- /*
- * If a compound datatype is split across multiple lines then indent
- * the continuation line.
- */
- info.line_pre = " %s ";
- info.line_cont = " %s ";
+ if (simple_output_g) {
+ info.idx_fmt = "";
+ info.line_ncols = 65535; /*something big*/
+ info.line_per_line = 1;
+ info.line_multi_new = 0;
+ info.line_pre = " ";
+ info.line_cont = " ";
+
+ info.arr_pre = "";
+ info.arr_suf = "";
+ info.arr_sep = " ";
+
+ info.cmpd_pre = "";
+ info.cmpd_suf = "";
+ info.cmpd_sep = " ";
+ if (label_g) info.cmpd_name = "%s=";
+
+ info.elmt_suf1 = " ";
+ info.str_locale = ESCAPE_HTML;
+
+ } else {
+ info.idx_fmt = "(%s)";
+ info.line_ncols = width_g;
+ info.line_multi_new = 1;
+ if (label_g) info.cmpd_name = "%s=";
+ info.line_pre = " %s ";
+ info.line_cont = " %s ";
+ info.str_repeat = 8;
+ }
+
if (hexdump_g) {
/*
* Print all data in hexadecimal format if the `-x' or `--hexdump'
@@ -1136,7 +1160,9 @@ dump_dataset_values(hid_t dset)
info.ascii = TRUE;
info.elmt_suf1 = "";
info.elmt_suf2 = "";
- info.line_pre =" %s \"";
+ strcpy(string_prefix, info.line_pre);
+ strcat(string_prefix, "\"");
+ info.line_pre = string_prefix;
info.line_suf = "\"";
}
@@ -1211,12 +1237,14 @@ list_attr (hid_t obj, const char *attr_name, void UNUSED *op_data)
info.line_1st = " Data: ";
info.line_pre = " ";
info.line_cont = " ";
+ info.str_repeat = 8;
} else {
printf(" Data:\n");
info.idx_fmt = "(%s)";
info.line_pre = " %s ";
info.line_cont = " %s ";
+ info.str_repeat = 8;
}
info.line_ncols = width_g;
if (label_g) info.cmpd_name = "%s=";
@@ -1924,6 +1952,8 @@ main (int argc, char *argv[])
} else if (!strcmp(argv[argno], "--recursive")) {
recursive_g = TRUE;
fullname_g = TRUE;
+ } else if (!strcmp(argv[argno], "--simple")) {
+ simple_output_g = TRUE;
} else if (!strcmp(argv[argno], "--string")) {
string_g = TRUE;
} else if (!strncmp(argv[argno], "--width=", 8)) {
@@ -1996,6 +2026,9 @@ main (int argc, char *argv[])
recursive_g = TRUE;
fullname_g = TRUE;
break;
+ case 'S': /* --simple */
+ simple_output_g = TRUE;
+ break;
case 's': /* --string */
string_g = TRUE;
break;