diff options
author | Robb Matzke <matzke@llnl.gov> | 1999-09-30 16:14:14 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1999-09-30 16:14:14 (GMT) |
commit | bdf0dbf7ed9a671cf915de65006ae5a5379c6941 (patch) | |
tree | 2117c72f7f589bd030d32dbc398c836e8a4524c8 | |
parent | 03d438979b7bc6a08d25d121676bbd2083254c80 (diff) | |
download | hdf5-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.
-rw-r--r-- | src/H5FDmpio.h | 5 | ||||
-rw-r--r-- | src/H5public.h | 42 | ||||
-rw-r--r-- | test/h5test.h | 6 | ||||
-rw-r--r-- | tools/h5ls.c | 61 | ||||
-rw-r--r-- | tools/h5tools.c | 177 | ||||
-rw-r--r-- | tools/h5tools.h | 19 |
6 files changed, 214 insertions, 96 deletions
diff --git a/src/H5FDmpio.h b/src/H5FDmpio.h index fb61498..dab4d5e 100644 --- a/src/H5FDmpio.h +++ b/src/H5FDmpio.h @@ -46,8 +46,13 @@ __DLL__ htri_t H5FD_mpio_tas_allsame(H5FD_t *_file, hbool_t newval); __DLL__ MPI_Comm H5FD_mpio_communicator(H5FD_t *_file); __DLL__ herr_t H5FD_mpio_setup(H5FD_t *_file, MPI_Datatype btype, MPI_Datatype ftype, haddr_t disp, hbool_t use_types); +<<<<<<<<<<<<<< variant A +__DLL__herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file); +__DLL__herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file); +>>>>>>>>>>>>>> variant B __DLL__ herr_t H5FD_mpio_wait_for_left_neighbor(H5FD_t *file); __DLL__ herr_t H5FD_mpio_signal_right_neighbor(H5FD_t *file); +======= end of combination #endif /*HAVE_PARALLEL*/ diff --git a/src/H5public.h b/src/H5public.h index dadd5b0..0d1c498 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -23,12 +23,50 @@ static char RcsId[] = "@(#)$Revision$"; #ifndef _H5public_H #define _H5public_H +/* + * Undefine things that might get redefined in the H5config.h file if hdf5 is + * being included by other packages that use autoconf. The problem is that + * if the C preprocessor emits warning messages about redefinitions then + * autoconf will become confused and think that the hdf5 header file doesn't + * exist. + */ +#undef SIZEOF_INT8_T +#undef SIZEOF_INT_FAST8_T +#undef SIZEOF_INT_LEAST8_T +#undef SIZEOF_UINT8_T +#undef SIZEOF_UINT_FAST8_T +#undef SIZEOF_UINT_LEAST8_T + +#undef SIZEOF_INT16_T +#undef SIZEOF_INT_FAST16_T +#undef SIZEOF_INT_LEAST16_T +#undef SIZEOF_UINT16_T +#undef SIZEOF_UINT_FAST16_T +#undef SIZEOF_UINT_LEAST16_T + +#undef SIZEOF_INT32_T +#undef SIZEOF_INT_FAST32_T +#undef SIZEOF_INT_LEAST32_T +#undef SIZEOF_UINT32_T +#undef SIZEOF_UINT_FAST32_T +#undef SIZEOF_UINT_LEAST32_T + +#undef SIZEOF_INT64_T +#undef SIZEOF_INT_FAST64_T +#undef SIZEOF_INT_LEAST64_T +#undef SIZEOF_UINT64_T +#undef SIZEOF_UINT_FAST64_T +#undef SIZEOF_UINT_LEAST64_T + +/* Include files for public use... */ #include <H5config.h> /*from configure */ #include <sys/types.h> #ifdef STDC_HEADERS # include <limits.h> /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */ #endif - +#ifdef HAVE_STDINT_H +# include <stdint.h> /*for C9x types */ +#endif #ifdef HAVE_STDDEF_H # include <stddef.h> #endif @@ -119,7 +157,7 @@ typedef ssize_t hssize_t; #elif SIZEOF_LONG_LONG>=8 typedef unsigned long long haddr_t; # define HADDR_UNDEF ((haddr_t)(long long)(-1)) -# elif SIZEOF___INT64>=8 +#elif SIZEOF___INT64>=8 typedef unsigned __int64 haddr_t; # define HADDR_UNDEF ((haddr_t)(__int64)(-1)) #else diff --git a/test/h5test.h b/test/h5test.h index 98f6060..fd8a21d 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -39,9 +39,9 @@ extern const char *FILENAME[]; * the FAILED() macro is invoked automatically when an API function fails. */ #define TESTING(WHAT) {printf("%-70s", "Testing " WHAT); fflush(stdout);} -#define PASSED() puts(" PASSED") -#define FAILED() puts("*FAILED*") -#define SKIPPED() puts(" -SKIP-") +#define PASSED() {puts(" PASSED");fflush(stdout);} +#define FAILED() {puts("*FAILED*");fflush(stdout);} +#define SKIPPED() {puts(" -SKIP-");fflush(stdout);} /* * Print the current location on the standard output stream. 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; diff --git a/tools/h5tools.c b/tools/h5tools.c index 36ce038..5dbb7ff 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -61,12 +61,6 @@ int print_data(hid_t oid, hid_t _p_type, int obj_data); #define REPEAT_VERBOSE /* - * This is the original value of the repeat_threshold in the h5dump_sprint - * function. - */ -#define H5DEFAULT_REPEAT_THRESHOLD 8 - -/* * The output functions need a temporary buffer to hold a piece of the * dataset while it's being printed. This constant sets the limit on the * size of that temporary buffer in bytes. For efficiency's sake, choose the @@ -97,6 +91,7 @@ typedef struct h5dump_str_t { /* Output variables */ typedef struct h5dump_context_t { size_t cur_column; /*current column for output */ + size_t cur_elmt; /*current element/output line */ int need_prefix; /*is line prefix needed? */ int ndims; /*dimensionality */ hsize_t p_min_idx[H5S_MAX_RANK]; /*min selected index */ @@ -613,11 +608,6 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5G_stat_t sb; - int repeat_threshold = H5DEFAULT_REPEAT_THRESHOLD; - - if (programtype == H5DUMP){ - repeat_threshold = -1; /*-1 means any amount of repeat allowed*/ - } /* Build default formats for long long types */ if (!fmt_llong[0]) { @@ -645,37 +635,45 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { - switch (*((char*)vp)) { - case '"': - h5dump_str_append(str, "\\\""); - break; - case '\\': - h5dump_str_append(str, "\\\\"); - break; - case '\b': - h5dump_str_append(str, "\\b"); - break; - case '\f': - h5dump_str_append(str, "\\f"); - break; - case '\n': - h5dump_str_append(str, "\\n"); - break; - case '\r': - h5dump_str_append(str, "\\r"); - break; - case '\t': - h5dump_str_append(str, "\\t"); - break; - default: - if (isprint((int)(*((char*)vp)))) { - h5dump_str_append(str, "%c", *((char*)vp)); + if (ESCAPE_HTML==info->str_locale) { + if (*((char*)vp)<=' ' || *((char*)vp)>'~') { + h5dump_str_append(str, "%%%02X", *((unsigned char*)vp)); } else { - h5dump_str_append(str, "\\%03o", *((unsigned char*)vp)); + h5dump_str_append(str, "%c", *((char*)vp)); + } + } else { + switch (*((char*)vp)) { + case '"': + h5dump_str_append(str, "\\\""); + break; + case '\\': + h5dump_str_append(str, "\\\\"); + break; + case '\b': + h5dump_str_append(str, "\\b"); + break; + case '\f': + h5dump_str_append(str, "\\f"); + break; + case '\n': + h5dump_str_append(str, "\\n"); + break; + case '\r': + h5dump_str_append(str, "\\r"); + break; + case '\t': + h5dump_str_append(str, "\\t"); + break; + default: + if (isprint(*((char*)vp))) { + h5dump_str_append(str, "%c", *((char*)vp)); + } else { + h5dump_str_append(str, "\\%03o", *((unsigned char*)vp)); + } + break; } - break; } - + } else if (H5T_STRING==H5Tget_class(type)) { size = H5Tget_size(type); quote = '\0'; @@ -687,14 +685,12 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, /* * Count how many times the next character repeats. If the - * threshold is negative then that means it can repeat any number + * threshold is zero then that means it can repeat any number * of times. */ - if (repeat_threshold >= 0) { - j=1; + j=1; + if (info->str_repeat>0) { while (i+j<size && ((char*)vp)[i]==((char*)vp)[i+j]) j++; - } else { - j = repeat_threshold - 1; } /* @@ -703,7 +699,7 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, * the characters, then make sure the character to be repeated is * in it's own quote. */ - if (j>repeat_threshold) { + if (info->str_repeat>0 && j>info->str_repeat) { if (quote) h5dump_str_append(str, "%c", quote); quote = '\''; h5dump_str_append(str, "%s%c", i?" ":"", quote); @@ -713,39 +709,48 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, } /* Print the character */ - switch (((char*)vp)[i]) { - case '"': - h5dump_str_append(str, "\\\""); - break; - case '\\': - h5dump_str_append(str, "\\\\"); - break; - case '\b': - h5dump_str_append(str, "\\b"); - break; - case '\f': - h5dump_str_append(str, "\\f"); - break; - case '\n': - h5dump_str_append(str, "\\n"); - break; - case '\r': - h5dump_str_append(str, "\\r"); - break; - case '\t': - h5dump_str_append(str, "\\t"); - break; - default: - if (isprint((int)((char*)vp)[i])) { - h5dump_str_append(str, "%c", ((char*)vp)[i]); + if (ESCAPE_HTML==info->str_locale) { + if (((char*)vp)[i]<=' ' || ((char*)vp)[i]>'~') { + h5dump_str_append(str, "%%%02X", ((unsigned char*)vp)[i]); } else { - h5dump_str_append(str, "\\%03o", ((unsigned char*)vp)[i]); + h5dump_str_append(str, "%c", ((char*)vp)[i]); + } + } else { + switch (((char*)vp)[i]) { + case '"': + h5dump_str_append(str, "\\\""); + break; + case '\\': + h5dump_str_append(str, "\\\\"); + break; + case '\b': + h5dump_str_append(str, "\\b"); + break; + case '\f': + h5dump_str_append(str, "\\f"); + break; + case '\n': + h5dump_str_append(str, "\\n"); + break; + case '\r': + h5dump_str_append(str, "\\r"); + break; + case '\t': + h5dump_str_append(str, "\\t"); + break; + default: + if (isprint(((char*)vp)[i])) { + h5dump_str_append(str, "%c", ((char*)vp)[i]); + } else { + h5dump_str_append(str, "\\%03o", + ((unsigned char*)vp)[i]); + } + break; } - break; } - + /* Print the repeat count */ - if (j>repeat_threshold) { + if (info->str_repeat && j>info->str_repeat) { #ifdef REPEAT_VERBOSE h5dump_str_append(str, "%c repeats %d times", quote, j-1); #else @@ -756,6 +761,11 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, } } if (quote) h5dump_str_append(str, "%c", quote); + + if (0==i) { + h5dump_str_append(str, "\"\""); /*empty string*/ + } + } else if (H5Tequal(type, H5T_NATIVE_INT)) { h5dump_str_append(str, OPT(info->fmt_int, "%d"), @@ -1001,7 +1011,9 @@ h5dump_ncols(const char *s) * Monday, April 26, 1999 * * Modifications: - * + * Robb Matzke, 1999-09-29 + * If a new prefix is printed then the current element number is + * set back to zero. *------------------------------------------------------------------------- */ static void @@ -1036,6 +1048,7 @@ h5dump_simple_prefix(FILE *stream, const h5dump_t *info, stream); } ctx->cur_column = ctx->prev_prefix_len = h5dump_str_len(&prefix); + ctx->cur_elmt = 0; ctx->need_prefix = 0; /* Free string */ @@ -1065,6 +1078,10 @@ h5dump_simple_prefix(FILE *stream, const h5dump_t *info, * The `container' argument is the optional dataset for * reference types. * + * Robb Matzke, 1999-09-29 + * Understands the `per_line' property which indicates that + * every Nth element should begin a new line. + * *------------------------------------------------------------------------- */ static void @@ -1087,7 +1104,7 @@ h5dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, if (info->line_ncols>0) ncols = info->line_ncols; h5dump_simple_prefix(stream, info, ctx, 0, 0); - for (i=0; i<nelmts; i++) { + for (i=0; i<nelmts; i++, ctx->cur_elmt++) { /* Render the element */ h5dump_str_reset(&buffer); @@ -1135,6 +1152,14 @@ h5dump_simple_data(FILE *stream, const h5dump_t *info, hid_t container, strlen(OPT(info->line_suf, ""))) > ncols) { ctx->need_prefix = TRUE; } + + /* + * If too many elements have already been printed then we need to + * start a new line. + */ + if (info->line_per_line>0 && ctx->cur_elmt>=info->line_per_line) { + ctx->need_prefix = TRUE; + } /* * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause diff --git a/tools/h5tools.h b/tools/h5tools.h index da63be0..d962cee 100644 --- a/tools/h5tools.h +++ b/tools/h5tools.h @@ -13,6 +13,8 @@ #include <hdf5.h> #include <stdio.h> +#define ESCAPE_HTML 1 + /* * Information about how to format output. */ @@ -77,6 +79,15 @@ typedef struct h5dump_t { * escape. If `ascii' is zero then then 1-byte integers are * printed as numeric values. The default is zero. * + * str_locale: Determines how strings are printed. If zero then strings + * are printed like in C except. If set to ESCAPE_HTML then + * strings are printed using HTML encoding where each + * character not in the class [a-zA-Z0-9] is substituted + * with `%XX' where `X' is a hexadecimal digit. + * + * str_repeat: If set to non-zero then any character value repeated N + * or more times is printed as 'C'*N + * * Numeric data is also subject to the formats for individual elements. */ hbool_t raw; @@ -94,6 +105,8 @@ typedef struct h5dump_t { const char *fmt_double; const char *fmt_float; int ascii; + int str_locale; + int str_repeat; /* * Fields associated with compound array members. @@ -178,7 +191,10 @@ typedef struct h5dump_t { /* * Fields associated with entire lines. * - * ncols: Number of columns per line defaults to 80. + * ncols: Number of columns per line defaults to 80. + * + * per_line: If this field has a positive value then every Nth element + * will be printed at the beginning of a line. * * pre: Each line of output contains an optional prefix area * before the data. This area can contain the index for the @@ -224,6 +240,7 @@ typedef struct h5dump_t { * unless it wouldn't fit. */ int line_ncols; /*columns of output */ + size_t line_per_line; /*max elements per line */ const char *line_pre; /*prefix at front of each line */ const char *line_1st; /*alternate pre. on first line */ const char *line_cont; /*alternate pre. on continuation*/ |