diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5tools.c | 254 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 6 | ||||
-rw-r--r-- | tools/lib/h5tools_filters.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.c | 40 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 356 | ||||
-rw-r--r-- | tools/lib/h5tools_str.h | 6 | ||||
-rw-r--r-- | tools/lib/h5tools_type.c | 12 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 42 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.h | 18 |
9 files changed, 369 insertions, 369 deletions
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 17eb247..f76d4d3 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -17,8 +17,8 @@ * Programmer: Robb Matzke <matzke@llnl.gov> * Thursday, July 23, 1998 * - * Purpose: A library for displaying the values of a dataset in a human - * readable format. + * Purpose: A library for displaying the values of a dataset in a human + * readable format. */ #include <stdio.h> @@ -42,11 +42,11 @@ #define H5TOOLS_BUFSIZE (1024) #endif /* 1 */ -#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) +#define ALIGN(A,Z) ((((A) + (Z) - 1) / (Z)) * (Z)) /* global variables */ int compound_data; -FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */ +FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */ /* module-scoped variables */ static int h5tools_init_g; /* if h5tools lib has been initialized */ @@ -62,7 +62,7 @@ static const char *drivernames[]={ "multi", #ifdef H5_HAVE_STREAM "stream", -#endif /* H5_HAVE_STREAM */ +#endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL "mpio", "mpiposix" @@ -78,7 +78,7 @@ enum { ,MULTI_IDX #ifdef H5_HAVE_STREAM ,STREAM_IDX -#endif /* H5_HAVE_STREAM */ +#endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL ,MPIO_IDX ,MPIPOSIX_IDX @@ -105,17 +105,17 @@ void h5tools_init(void) { if (!h5tools_init_g) { - if (!rawdatastream) - rawdatastream = stdout; + if (!rawdatastream) + rawdatastream = stdout; - h5tools_init_g++; + h5tools_init_g++; } } /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library - * Purpose: Close the H5 Tools library + * Purpose: Close the H5 Tools library * Description: * Close or release resources such as files opened by the library. This * should be called after all other h5tools functions have been called. @@ -132,12 +132,12 @@ void h5tools_close(void) { if (h5tools_init_g) { - if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); - else - rawdatastream = NULL; - } + if (rawdatastream && rawdatastream != stdout) { + if (fclose(rawdatastream)) + perror("closing rawdatastream"); + else + rawdatastream = NULL; + } /* Clean up the reference path table, if it's been used */ term_ref_path_table(); @@ -145,14 +145,14 @@ h5tools_close(void) /* Shut down the library */ H5close(); - h5tools_init_g = 0; + h5tools_init_g = 0; } } /*------------------------------------------------------------------------- * Audience: Private * Chapter: H5Tools Library - * Purpose: Get a FAPL for a driver + * Purpose: Get a FAPL for a driver * Description: * Get a FAPL for a given VFL driver name. * Return: @@ -208,32 +208,32 @@ h5tools_get_fapl(const char *driver, unsigned *drivernum) if(drivernum) *drivernum = STREAM_IDX; } /* end if */ -#endif /* H5_HAVE_STREAM */ +#endif /* H5_HAVE_STREAM */ #ifdef H5_HAVE_PARALLEL } else if (!strcmp(driver, drivernames[MPIO_IDX])) { /* MPI-I/O Driver */ - /* check if MPI has been initialized. */ - if (!h5tools_mpi_init_g) - MPI_Initialized(&h5tools_mpi_init_g); + /* check if MPI has been initialized. */ + if (!h5tools_mpi_init_g) + MPI_Initialized(&h5tools_mpi_init_g); if (h5tools_mpi_init_g && ((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0)) { if (H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL)<0) - goto error; + goto error; if(drivernum) *drivernum = MPIO_IDX; } /* end if */ } else if (!strcmp(driver, drivernames[MPIPOSIX_IDX])) { /* MPI-I/O Driver */ - /* check if MPI has been initialized. */ - if (!h5tools_mpi_init_g) - MPI_Initialized(&h5tools_mpi_init_g); + /* check if MPI has been initialized. */ + if (!h5tools_mpi_init_g) + MPI_Initialized(&h5tools_mpi_init_g); if (h5tools_mpi_init_g && ((fapl = H5Pcreate(H5P_FILE_ACCESS))>=0)) { #ifdef H5_WANT_H5_V1_4_COMPAT if (H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD)<0) #else - if (H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD, TRUE)<0) + if (H5Pset_fapl_mpiposix(fapl, MPI_COMM_WORLD, TRUE)<0) #endif - goto error; + goto error; if(drivernum) *drivernum = MPIPOSIX_IDX; @@ -405,8 +405,8 @@ h5tools_ncols(const char *s) * Robb Matzke, 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. + * If a new prefix is printed then the current element number is set back + * to zero. * pvn, 2004-07-08 * Added support for printing array indices: * the indentation is printed before the prefix (printed one indentation @@ -423,16 +423,16 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, int i, indentlevel = 0; if (!ctx->need_prefix) - return; + return; memset(&prefix, 0, sizeof(h5tools_str_t)); memset(&str, 0, sizeof(h5tools_str_t)); /* Terminate previous line, if any */ if (ctx->cur_column) { - fputs(OPT(info->line_suf, ""), stream); + fputs(OPT(info->line_suf, ""), stream); putc('\n', stream); - fputs(OPT(info->line_sep, ""), stream); + fputs(OPT(info->line_sep, ""), stream); } /* Calculate new prefix */ @@ -449,7 +449,7 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * the ctx->indent_level is negative so we need to skip the above and * just print out the default indent levels. */ - indentlevel = ctx->default_indent_level; + indentlevel = ctx->default_indent_level; } /* when printing array indices, print the indentation before the prefix @@ -507,23 +507,23 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, * Programmer: * Robb Matzke, Monday, April 26, 1999 * Modifications: - * Robb Matzke, 1999-06-04 - * The `container' argument is the optional dataset for reference types. + * Robb Matzke, 1999-06-04 + * 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. + * Robb Matzke, 1999-09-29 + * Understands the `per_line' property which indicates that every Nth + * element should begin a new line. * * Robb Matzke, LLNL, 2003-06-05 * Do not dereference the memory for a variable-length string here. * Deref in h5tools_str_sprint() instead so recursive types are * handled correctly. - * - * Pedro Vicente Nunes, THG, 2005-10-19 + * + * Pedro Vicente Nunes, THG, 2005-10-19 * pass to the prefix in h5tools_simple_prefix the total position - * instead of the current stripmine position i; this is necessary - * to print the array indices - * new field sm_pos in h5tools_context_t, the current stripmine element position + * instead of the current stripmine position i; this is necessary + * to print the array indices + * new field sm_pos in h5tools_context_t, the current stripmine element position *------------------------------------------------------------------------- */ void @@ -531,15 +531,15 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai h5tools_context_t *ctx/*in,out*/, unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { - unsigned char *mem = (unsigned char*)_mem; - hsize_t i; /*element counter */ - char *s, *section; /*a section of output */ - int secnum; /*section sequence number */ - size_t size; /*size of each datum */ - size_t ncols = 80; /*available output width */ - h5tools_str_t buffer; /*string into which to render */ - int multiline; /*datum was multiline */ - hsize_t curr_pos; /* total data element position */ + unsigned char *mem = (unsigned char*)_mem; + hsize_t i; /*element counter */ + char *s, *section; /*a section of output */ + int secnum; /*section sequence number */ + size_t size; /*size of each datum */ + size_t ncols = 80; /*available output width */ + h5tools_str_t buffer; /*string into which to render */ + int multiline; /*datum was multiline */ + hsize_t curr_pos; /* total data element position */ int elmt_counter = 0;/*counts the # elements printed. *I (ptl?) needed something that *isn't going to get reset when a new @@ -553,7 +553,7 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai size = H5Tget_size(type); if (info->line_ncols > 0) - ncols = info->line_ncols; + ncols = info->line_ncols; /* pass to the prefix in h5tools_simple_prefix the total position instead of the current stripmine position i; this is necessary @@ -664,8 +664,8 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai multiline++; /* pass to the prefix in h5tools_simple_prefix the total position - instead of the current stripmine position i; this is necessary - to print the array indices */ + instead of the current stripmine position i; this is necessary + to print the array indices */ curr_pos = ctx->sm_pos + i; h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); @@ -705,22 +705,22 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, hid_t dset int indentlevel) { herr_t ret; /*the value to return */ - hid_t f_space; /*file data space */ - int i, j; /*counters */ - hsize_t zero = 0; /*vector of zeros */ - unsigned int flags; /*buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ + hid_t f_space; /*file data space */ + int i, j; /*counters */ + hsize_t zero = 0; /*vector of zeros */ + unsigned int flags; /*buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ /* Print info */ - h5tools_context_t ctx; /*print context */ - size_t p_type_nbytes; /*size of memory type */ + h5tools_context_t ctx; /*print context */ + size_t p_type_nbytes; /*size of memory type */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - unsigned char *sm_buf = NULL; /*buffer for raw data */ - hid_t sm_space; /*stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nelmts; /*elements per stripmine*/ + unsigned char *sm_buf = NULL; /*buffer for raw data */ + hid_t sm_space; /*stripmine data space */ hsize_t count; @@ -871,7 +871,7 @@ done: /*------------------------------------------------------------------------- * Audience: Public * Chapter: H5Tools Library - * Purpose: Print some values from a dataset with a simple data space. + * Purpose: Print some values from a dataset with a simple data space. * Description: * This is a special case of h5tools_dump_dset(). This function only * intended for dumping datasets -- it does strip mining and some other @@ -890,30 +890,30 @@ static int h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, hid_t p_type, int indentlevel) { - hid_t f_space; /*file data space */ - hsize_t elmtno; /*counter */ - int i; /*counter */ - int carry; /*counter carry value */ - hsize_t zero[8]; /*vector of zeros */ - unsigned int flags; /*buffer extent flags */ - hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ + hid_t f_space; /*file data space */ + hsize_t elmtno; /*counter */ + int i; /*counter */ + int carry; /*counter carry value */ + hsize_t zero[8]; /*vector of zeros */ + unsigned int flags; /*buffer extent flags */ + hsize_t total_size[H5S_MAX_RANK];/*total size of dataset*/ /* Print info */ - h5tools_context_t ctx; /*print context */ - size_t p_type_nbytes; /*size of memory type */ - hsize_t p_nelmts; /*total selected elmts */ + h5tools_context_t ctx; /*print context */ + size_t p_type_nbytes; /*size of memory type */ + hsize_t p_nelmts; /*total selected elmts */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ - hsize_t sm_nbytes; /*bytes per stripmine */ - hsize_t sm_nelmts; /*elements per stripmine*/ - unsigned char *sm_buf = NULL; /*buffer for raw data */ - hid_t sm_space; /*stripmine data space */ + hsize_t sm_size[H5S_MAX_RANK]; /*stripmine size */ + hsize_t sm_nbytes; /*bytes per stripmine */ + hsize_t sm_nelmts; /*elements per stripmine*/ + unsigned char *sm_buf = NULL; /*buffer for raw data */ + hid_t sm_space; /*stripmine data space */ /* Hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ - hsize_t hs_nelmts; /*elements in request */ + hsize_t hs_offset[H5S_MAX_RANK];/*starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /*size this pass */ + hsize_t hs_nelmts; /*elements in request */ /* VL data special information */ unsigned int vl_data = 0; /*contains VL datatypes */ @@ -1065,16 +1065,16 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, hid_t dset, } /*------------------------------------------------------------------------- - * Function: h5tools_dump_simple_mem + * Function: h5tools_dump_simple_mem * - * Purpose: Print some values from memory with a simple data space. - * This is a special case of h5tools_dump_mem(). + * Purpose: Print some values from memory with a simple data space. + * This is a special case of h5tools_dump_mem(). * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: @@ -1085,9 +1085,9 @@ static int h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t type, hid_t space, void *mem, int indentlevel) { - int i; /*counters */ - hsize_t nelmts; /*total selected elmts */ - h5tools_context_t ctx; /*printing context */ + int i; /*counters */ + hsize_t nelmts; /*total selected elmts */ + h5tools_context_t ctx; /*printing context */ /* * Check that everything looks okay. The dimensionality must not be too @@ -1139,34 +1139,34 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, } /*------------------------------------------------------------------------- - * Function: h5tools_dump_dset + * Function: h5tools_dump_dset * - * Purpose: Print some values from a dataset DSET to the file STREAM - * after converting all types to P_TYPE (which should be a - * native type). If P_TYPE is a negative value then it will be - * computed from the dataset type using only native types. + * Purpose: Print some values from a dataset DSET to the file STREAM + * after converting all types to P_TYPE (which should be a + * native type). If P_TYPE is a negative value then it will be + * computed from the dataset type using only native types. * - * Note: This function is intended only for datasets since it does - * some things like strip mining which are unnecessary for - * smaller objects such as attributes. The easiest way to print - * small objects is to read the object into memory and call - * h5tools_dump_mem(). + * Note: This function is intended only for datasets since it does + * some things like strip mining which are unnecessary for + * smaller objects such as attributes. The easiest way to print + * small objects is to read the object into memory and call + * h5tools_dump_mem(). * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: - * Robb Matzke, 1999-06-07 - * If info->raw is set then the memory datatype will be the same - * as the file datatype. + * Robb Matzke, 1999-06-07 + * If info->raw is set then the memory datatype will be the same + * as the file datatype. * - * Bill Wendling, 2001-02-27 - * Renamed to ``h5tools_dump_dset'' and added the subsetting - * parameter. + * Bill Wendling, 2001-02-27 + * Renamed to ``h5tools_dump_dset'' and added the subsetting + * parameter. * *------------------------------------------------------------------------- */ @@ -1231,17 +1231,17 @@ done: } /*------------------------------------------------------------------------- - * Function: h5tools_dump_mem + * Function: h5tools_dump_mem * - * Purpose: Displays the data contained in MEM. MEM must have the - * specified data TYPE and SPACE. Currently only simple data - * spaces are allowed and only the `all' selection. + * Purpose: Displays the data contained in MEM. MEM must have the + * specified data TYPE and SPACE. Currently only simple data + * spaces are allowed and only the `all' selection. * - * Return: Success: SUCCEED + * Return: Success: SUCCEED * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, January 20, 1999 * * Modifications: @@ -1256,16 +1256,16 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t /* Use default values */ if (!stream) - stream = stdout; + stream = stdout; if (!info) { - memset(&info_dflt, 0, sizeof(info_dflt)); - info = &info_dflt; + memset(&info_dflt, 0, sizeof(info_dflt)); + info = &info_dflt; } /* Check the data space */ if (H5Sis_simple(space) <= 0) - return -1; + return -1; return h5tools_dump_simple_mem(stream, info, obj_id, type, space, mem, indentlevel); @@ -1284,7 +1284,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, hid_t obj_id, hid_t * *------------------------------------------------------------------------- */ -void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) +void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) { int i; diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index 7dba8f5..bbb4d40 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -27,8 +27,8 @@ #define ESCAPE_HTML 1 #define OPT(X,S) ((X) ? (X) : (S)) #define OPTIONAL_LINE_BREAK "\001" /* Special strings embedded in the output */ -#define START_OF_DATA 0x0001 -#define END_OF_DATA 0x0002 +#define START_OF_DATA 0x0001 +#define END_OF_DATA 0x0002 /* * The output functions need a temporary buffer to hold a piece of the @@ -402,5 +402,5 @@ extern int h5tools_can_encode(H5Z_filter_t filtn); void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims); -#endif /* H5TOOLS_H__ */ +#endif /* H5TOOLS_H__ */ diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 907448d..7966f04 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -93,7 +93,7 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr return 0; /*------------------------------------------------------------------------- - * H5Z_FILTER_DEFLATE 1 , deflation like gzip + * H5Z_FILTER_DEFLATE 1 , deflation like gzip *------------------------------------------------------------------------- */ case H5Z_FILTER_DEFLATE: @@ -186,7 +186,7 @@ int h5tools_can_encode( H5Z_filter_t filtn) switch (filtn) { - /* user defined filter */ + /* user defined filter */ default: return 0; diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index d136fa2..ab893f3 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -75,15 +75,15 @@ init_ref_path_table(hid_t fid) /* Create skip list to store reference path information */ if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) - return (-1); + return (-1); if((root_path = HDstrdup("/")) == NULL) - return (-1); + return (-1); if(H5Gget_objinfo(fid, "/", TRUE, &sb)<0) { - /* fatal error? */ - HDfree(root_path); - return (-1); + /* fatal error? */ + HDfree(root_path); + return (-1); } /* Insert into table (takes ownership of path) */ @@ -164,8 +164,8 @@ ref_path_table_lookup(const char *thepath) /* Get object ID for object at path */ if(H5Gget_objinfo(thefile, thepath, TRUE, &sb)<0) - /* fatal error ? */ - return HADDR_UNDEF; + /* fatal error ? */ + return HADDR_UNDEF; /* Return OID or HADDR_UNDEF */ objno = ((haddr_t)sb.objno[1] << (8*sizeof(long))) | (haddr_t)sb.objno[0]; @@ -300,10 +300,10 @@ lookup_ref_path(haddr_t ref) { uint8_t *p; /* Pointer to reference to translate */ haddr_t addr; /* Resulting address */ - unsigned i; /* Local index variable */ - haddr_t tmp; /* Temporary portion of address */ - uint8_t c; /* Byte from address */ - hbool_t all_zero = TRUE; /* If the address is all zeros, make into HADDR_UNDEF */ + unsigned i; /* Local index variable */ + haddr_t tmp; /* Temporary portion of address */ + uint8_t c; /* Byte from address */ + hbool_t all_zero = TRUE; /* If the address is all zeros, make into HADDR_UNDEF */ ref_path_node_t *node; /* Ref path node found for address */ /* Be safer for h5ls */ @@ -315,17 +315,17 @@ lookup_ref_path(haddr_t ref) addr = 0; for (i=0; i<sizeof(haddr_t); i++) { - c = *p++; - if (c != 0xff) + c = *p++; + if (c != 0xff) all_zero = FALSE; - if (i<sizeof(haddr_t)) { - tmp = c; - tmp <<= (i * 8); /*use tmp to get casting right */ - addr |= tmp; - } else if (!all_zero) { - assert(0 == *p); /*overflow */ - } + if (i<sizeof(haddr_t)) { + tmp = c; + tmp <<= (i * 8); /*use tmp to get casting right */ + addr |= tmp; + } else if (!all_zero) { + assert(0 == *p); /*overflow */ + } } if (all_zero) addr = HADDR_UNDEF; diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 430bc6d..56baccf 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -33,11 +33,11 @@ * If REPEAT_VERBOSE is defined then character strings will be printed so * that repeated character sequences like "AAAAAAAAAA" are displayed as * - * 'A' repeates 9 times + * 'A' repeates 9 times * * Otherwise the format is more Perl-like * - * 'A'*10 + * 'A'*10 * */ #define REPEAT_VERBOSE @@ -49,14 +49,14 @@ static char *h5tools_escape(char *s, size_t size); static hbool_t h5tools_is_zero(const void *_mem, size_t size); /*------------------------------------------------------------------------- - * Function: h5tools_str_close + * Function: h5tools_str_close * - * Purpose: Closes a string by releasing it's memory and setting the size - * information to zero. + * Purpose: Closes a string by releasing it's memory and setting the size + * information to zero. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -73,16 +73,16 @@ h5tools_str_close(h5tools_str_t *str) } /*------------------------------------------------------------------------- - * Function: h5tools_str_len + * Function: h5tools_str_len * - * Purpose: Returns the length of the string, not counting the null - * terminator. + * Purpose: Returns the length of the string, not counting the null + * terminator. * - * Return: Success: Length of string + * Return: Success: Length of string * - * Failure: 0 + * Failure: 0 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -96,16 +96,16 @@ h5tools_str_len(h5tools_str_t *str) } /*------------------------------------------------------------------------- - * Function: h5tools_str_append + * Function: h5tools_str_append * - * Purpose: Formats variable arguments according to printf() format - * string and appends the result to variable length string STR. + * Purpose: Formats variable arguments according to printf() format + * string and appends the result to variable length string STR. * - * Return: Success: Pointer to buffer containing result. + * Return: Success: Pointer to buffer containing result. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -113,7 +113,7 @@ h5tools_str_len(h5tools_str_t *str) * Major change: need to check results of vsnprintf to * handle errors, empty format, and overflows. * - * Programmer: REMcG Matzke + * Programmer: REMcG Matzke * June 16, 2004 * *------------------------------------------------------------------------- @@ -127,11 +127,11 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) /* Make sure we have some memory into which to print */ if (!str->s || str->nalloc <= 0) { - str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); - assert(str->s); - str->s[0] = '\0'; - str->len = 0; + str->nalloc = STR_INIT_LEN; + str->s = malloc(str->nalloc); + assert(str->s); + str->s[0] = '\0'; + str->len = 0; } if (strlen(fmt) == 0) { @@ -143,37 +143,37 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) /* Format the arguments and append to the value already in `str' */ while (1) { /* How many bytes available for new value, counting the new NUL */ - size_t avail = str->nalloc - str->len; + size_t avail = str->nalloc - str->len; - int nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap); + int nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap); - if (nchars<0) { + if (nchars<0) { /* failure, such as bad format */ va_end(ap); - return NULL; + return NULL; } - if ((size_t)nchars>=avail || - (0==nchars && (strcmp(fmt,"%s") ))) { - /* Truncation return value as documented by C99, or zero return value with either of the + if ((size_t)nchars>=avail || + (0==nchars && (strcmp(fmt,"%s") ))) { + /* Truncation return value as documented by C99, or zero return value with either of the * following conditions, each of which indicates that the proper C99 return value probably * should have been positive when the format string is * something other than "%s" * Alocate at least twice as much space and try again. */ - size_t newsize = MAX(str->len+nchars+1, 2*str->nalloc); - assert(newsize > str->nalloc); /*overflow*/ + size_t newsize = MAX(str->len+nchars+1, 2*str->nalloc); + assert(newsize > str->nalloc); /*overflow*/ #ifndef H5_HAVE_VSNPRINTF - /* If we even made it this far... the HDvsnprintf() clobbered memory: SIGSEGV probable*/ - abort(); + /* If we even made it this far... the HDvsnprintf() clobbered memory: SIGSEGV probable*/ + abort(); #endif - str->s = realloc(str->s, newsize); - assert(str->s); - str->nalloc = newsize; - } else { - /* Success */ - str->len += nchars; - break; + str->s = realloc(str->s, newsize); + assert(str->s); + str->nalloc = newsize; + } else { + /* Success */ + str->len += nchars; + break; } } va_end(ap); @@ -181,17 +181,17 @@ h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...) } /*------------------------------------------------------------------------- - * Function: h5tools_str_reset + * Function: h5tools_str_reset * - * Purpose: Reset the string to the empty value. If no memory is - * allocated yet then initialize the h5tools_str_t struct. + * Purpose: Reset the string to the empty value. If no memory is + * allocated yet then initialize the h5tools_str_t struct. * - * Return: Success: Ptr to the buffer which contains a null - * character as the first element. + * Return: Success: Ptr to the buffer which contains a null + * character as the first element. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -202,9 +202,9 @@ char * h5tools_str_reset(h5tools_str_t *str/*in,out*/) { if (!str->s || str->nalloc <= 0) { - str->nalloc = STR_INIT_LEN; - str->s = malloc(str->nalloc); - assert(str->s); + str->nalloc = STR_INIT_LEN; + str->s = malloc(str->nalloc); + assert(str->s); } str->s[0] = '\0'; @@ -213,15 +213,15 @@ h5tools_str_reset(h5tools_str_t *str/*in,out*/) } /*------------------------------------------------------------------------- - * Function: h5tools_str_trunc + * Function: h5tools_str_trunc * - * Purpose: Truncate a string to be at most SIZE characters. + * Purpose: Truncate a string to be at most SIZE characters. * - * Return: Success: Pointer to the string + * Return: Success: Pointer to the string * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -232,27 +232,27 @@ char * h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size) { if (size < str->len) { - str->len = size; - str->s[size] = '\0'; + str->len = size; + str->s[size] = '\0'; } return str->s; } /*------------------------------------------------------------------------- - * Function: h5tools_str_fmt + * Function: h5tools_str_fmt * - * Purpose: Reformat a string contents beginning at character START - * according to printf format FMT. FMT should contain no format - * specifiers except possibly the `%s' variety. For example, if - * the input string is `hello' and the format is "<<%s>>" then - * the output value will be "<<hello>>". + * Purpose: Reformat a string contents beginning at character START + * according to printf format FMT. FMT should contain no format + * specifiers except possibly the `%s' variety. For example, if + * the input string is `hello' and the format is "<<%s>>" then + * the output value will be "<<hello>>". * - * Return: Success: A pointer to the resulting string. + * Return: Success: A pointer to the resulting string. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -293,15 +293,15 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) } /*------------------------------------------------------------------------- - * Function: h5tools_str_prefix + * Function: h5tools_str_prefix * - * Purpose: Renders the line prefix value into string STR. + * Purpose: Renders the line prefix value into string STR. * - * Return: Success: Pointer to the prefix. + * Return: Success: Pointer to the prefix. * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: @@ -352,16 +352,16 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, } /*------------------------------------------------------------------------- - * Function: h5tools_str_dump_region + * Function: h5tools_str_dump_region * - * Purpose: Prints information about a dataspace region by appending - * the information to the specified string. + * Purpose: Prints information about a dataspace region by appending + * the information to the specified string. * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: NULL + * Failure: NULL * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, June 7, 1999 * * Modifications: @@ -371,10 +371,10 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, int h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t *info) { - hssize_t nblocks, npoints; + hssize_t nblocks, npoints; hsize_t alloc_size; hsize_t *ptdata; - int ndims = H5Sget_simple_extent_ndims(region); + int ndims = H5Sget_simple_extent_ndims(region); /* * These two functions fail if the region does not have blocks or points, @@ -452,13 +452,13 @@ h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t } /*------------------------------------------------------------------------- - * Function: h5tools_print_char + * Function: h5tools_print_char * - * Purpose: Shove a character into the STR. + * Purpose: Shove a character into the STR. * - * Return: Nothing + * Return: Nothing * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: @@ -534,28 +534,28 @@ h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, unsigned cha /*------------------------------------------------------------------------- - * Function: h5tools_str_sprint + * Function: h5tools_str_sprint * - * Purpose: Renders the value pointed to by VP of type TYPE into variable - * length string STR. + * Purpose: Renders the value pointed to by VP of type TYPE into variable + * length string STR. * - * Return: A pointer to memory containing the result or NULL on error. + * Return: A pointer to memory containing the result or NULL on error. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, July 23, 1998 * * Modifications: - * Robb Matzke, 1999-04-26 - * Made this function safe from overflow problems by allowing it - * to reallocate the output string. + * Robb Matzke, 1999-04-26 + * Made this function safe from overflow problems by allowing it + * to reallocate the output string. * - * Robb Matzke, 1999-06-04 - * Added support for object references. The new `container' - * argument is the dataset where the reference came from. + * Robb Matzke, 1999-06-04 + * Added support for object references. The new `container' + * argument is the dataset where the reference came from. * - * Robb Matzke, 1999-06-07 - * Added support for printing raw data. If info->raw is non-zero - * then data is printed in hexadecimal format. + * Robb Matzke, 1999-06-07 + * Added support for printing raw data. If info->raw is non-zero + * then data is printed in hexadecimal format. * * Robb Matzke, 2003-01-10 * Binary output format is dd:dd:... instead of 0xdddd... so it @@ -578,7 +578,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai char *cp_vp = (char *)vp; hid_t memb, obj, region; unsigned nmembs; - int otype; + int otype; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5G_stat_t sb; @@ -898,7 +898,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } } else if (H5Tget_class(type) == H5T_ARRAY) { int k, ndims; - hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; + hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; /* Get the array's base datatype for each element */ memb = H5Tget_super(type); @@ -909,11 +909,11 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Calculate the number of array elements */ for (k = 0, nelmts = 1; k < ndims; k++){ - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts)); + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts)); nelmts = (size_t)temp_nelmts; - } + } /* Print the opening bracket */ h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); @@ -949,7 +949,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* end for */ /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); H5Tclose(memb); } else if (H5Tget_class(type) == H5T_VLEN) { unsigned int i; @@ -1012,18 +1012,18 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /*------------------------------------------------------------------------- - * Function: h5tools_escape + * Function: h5tools_escape * - * Purpose: Changes all "funny" characters in S into standard C escape - * sequences. + * Purpose: Changes all "funny" characters in S into standard C escape + * sequences. * - * Return: Success: S + * Return: Success: S * - * Failure: NULL if the buffer would overflow. The - * buffer has as many left-to-right escapes as - * possible before overflow would have happened. + * Failure: NULL if the buffer would overflow. The + * buffer has as many left-to-right escapes as + * possible before overflow would have happened. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, April 26, 1999 * * Modifications: @@ -1039,76 +1039,76 @@ h5tools_escape(char *s/*in,out*/, size_t size) char octal[8]; for (i = 0; i < n; i++) { - switch (s[i]) { - case '\'': - escape = "\\\'"; - break; - case '\"': - escape = "\\\""; - break; - case '\\': - escape = "\\\\"; - break; - case '\?': - escape = "\\\?"; - break; - case '\a': - escape = "\\a"; - break; - case '\b': - escape = "\\b"; - break; - case '\f': - escape = "\\f"; - break; - case '\n': - escape = "\\n"; - break; - case '\r': - escape = "\\r"; - break; - case '\t': - escape = "\\t"; - break; - case '\v': - escape = "\\v"; - break; - default: - if (!isprint(s[i])) { - sprintf(octal, "\\%03o", (unsigned char)s[i]); - escape = octal; - } else { - escape = NULL; - } - - break; - } - - if (escape) { - size_t esc_size = strlen(escape); - - if (n + esc_size + 1 > size) - /*would overflow*/ - return NULL; - - memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ - memcpy(s + i, escape, esc_size); /*insert*/ - n += esc_size - 1; /* adjust total string size */ - i += esc_size; /* adjust string position */ - } + switch (s[i]) { + case '\'': + escape = "\\\'"; + break; + case '\"': + escape = "\\\""; + break; + case '\\': + escape = "\\\\"; + break; + case '\?': + escape = "\\\?"; + break; + case '\a': + escape = "\\a"; + break; + case '\b': + escape = "\\b"; + break; + case '\f': + escape = "\\f"; + break; + case '\n': + escape = "\\n"; + break; + case '\r': + escape = "\\r"; + break; + case '\t': + escape = "\\t"; + break; + case '\v': + escape = "\\v"; + break; + default: + if (!isprint(s[i])) { + sprintf(octal, "\\%03o", (unsigned char)s[i]); + escape = octal; + } else { + escape = NULL; + } + + break; + } + + if (escape) { + size_t esc_size = strlen(escape); + + if (n + esc_size + 1 > size) + /*would overflow*/ + return NULL; + + memmove(s + i + esc_size, s + i + 1, n - i); /*make room*/ + memcpy(s + i, escape, esc_size); /*insert*/ + n += esc_size - 1; /* adjust total string size */ + i += esc_size; /* adjust string position */ + } } return s; } /*------------------------------------------------------------------------- - * Function: h5tools_is_zero + * Function: h5tools_is_zero * - * Purpose: Determines if memory is initialized to all zero bytes. + * Purpose: Determines if memory is initialized to all zero bytes. * - * Return: TRUE if all bytes are zero; FALSE otherwise + * Return: TRUE if all bytes are zero; FALSE otherwise * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Monday, June 7, 1999 * * Modifications: @@ -1121,8 +1121,8 @@ h5tools_is_zero(const void *_mem, size_t size) const unsigned char *mem = (const unsigned char *)_mem; while (size-- > 0) - if (mem[size]) - return FALSE; + if (mem[size]) + return FALSE; return TRUE; } diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index c8874b3..1910bb5 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -21,9 +21,9 @@ #define H5TOOLS_STR_H__ typedef struct h5tools_str_t { - char *s; /*allocate string */ - size_t len; /*length of actual value */ - size_t nalloc; /*allocated size of string */ + char *s; /*allocate string */ + size_t len; /*length of actual value */ + size_t nalloc; /*allocated size of string */ } h5tools_str_t; extern void h5tools_str_close(h5tools_str_t *str); diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 6306773..77e6af3 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -16,16 +16,16 @@ #include "h5tools.h" /*------------------------------------------------------------------------- - * Function: h5tools_get_native_type + * Function: h5tools_get_native_type * - * Purpose: Wrapper around H5Tget_native_type() to work around - * Problems with bitfields. + * Purpose: Wrapper around H5Tget_native_type() to work around + * Problems with bitfields. * - * Return: Success: datatype ID + * Return: Success: datatype ID * - * Failure: FAIL + * Failure: FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, October 5, 2004 * * Modifications: diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 52d938e..33718c8 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -50,14 +50,14 @@ static herr_t find_objs_cb(hid_t group, const char *name, void *op_data); /*------------------------------------------------------------------------- - * Function: error_msg + * Function: error_msg * - * Purpose: Print a nicely formatted error message to stderr flushing the + * Purpose: Print a nicely formatted error message to stderr flushing the * stdout stream first. * - * Return: Nothing + * Return: Nothing * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: @@ -79,14 +79,14 @@ error_msg(const char *progname, const char *fmt, ...) /*------------------------------------------------------------------------- - * Function: warn_msg + * Function: warn_msg * - * Purpose: Print a nicely formatted warning message to stderr flushing + * Purpose: Print a nicely formatted warning message to stderr flushing * the stdout stream first. * - * Return: Nothing + * Return: Nothing * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Tuesday, 20. February 2001 * * Modifications: @@ -112,18 +112,18 @@ warn_msg(const char *progname, const char *fmt, ...) /*------------------------------------------------------------------------- - * Function: get_option + * Function: get_option * - * Purpose: Determine the command-line options a user specified. We can - * accept both short and long type command-lines. + * Purpose: Determine the command-line options a user specified. We can + * accept both short and long type command-lines. * - * Return: Success: The short valued "name" of the command line - * parameter or EOF if there are no more - * parameters to process. + * Return: Success: The short valued "name" of the command line + * parameter or EOF if there are no more + * parameters to process. * - * Failure: A question mark. + * Failure: A question mark. * - * Programmer: Bill Wendling + * Programmer: Bill Wendling * Friday, 5. January 2001 * * Modifications: @@ -283,7 +283,7 @@ indentation(int x) * Function: print_version * * Purpose: Print the program name and the version information which is - * defined the same as the HDF5 library version. + * defined the same as the HDF5 library version. * * Return: void * @@ -378,9 +378,9 @@ dump_table(char* tablename, table_t *table) printf("%s: # of entries = %d\n", tablename,table->nobjs); for (u = 0; u < table->nobjs; u++) - HDfprintf(stdout,"%a %s %d %d\n", table->objs[u].objno, - table->objs[u].objname, - table->objs[u].displayed, table->objs[u].recorded); + HDfprintf(stdout,"%a %s %d %d\n", table->objs[u].objno, + table->objs[u].objname, + table->objs[u].displayed, table->objs[u].recorded); } @@ -430,7 +430,7 @@ search_obj(table_t *table, unsigned long *_objno) for (u = 0; u < table->nobjs; u++) if (table->objs[u].objno == objno) - return &(table->objs[u]); + return &(table->objs[u]); return NULL; } diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h index 685a6e4..c8be65c 100644 --- a/tools/lib/h5tools_utils.h +++ b/tools/lib/h5tools_utils.h @@ -33,7 +33,7 @@ extern const char *opt_arg; /* flag argument (or value) */ enum { no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ + require_arg, /* requires an argument */ optional_arg /* argument is optional */ }; @@ -44,23 +44,23 @@ enum { * the option. The long options are specified in the following way: * * struct long_options foo[] = { - * { "filename", require_arg, 'f' }, - * { "append", no_arg, 'a' }, - * { "width", require_arg, 'w' }, - * { NULL, 0, 0 } + * { "filename", require_arg, 'f' }, + * { "append", no_arg, 'a' }, + * { "width", require_arg, 'w' }, + * { NULL, 0, 0 } * }; * * Long named options can have arguments specified as either: * - * ``--param=arg'' or ``--param arg'' + * ``--param=arg'' or ``--param arg'' * * Short named options can have arguments specified as either: * - * ``-w80'' or ``-w 80'' + * ``-w80'' or ``-w 80'' * * and can have more than one short named option specified at one time: * - * -aw80 + * -aw80 * * in which case those options which expect an argument need to come at the * end. @@ -116,4 +116,4 @@ extern herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table); extern obj_t *search_obj(table_t *temp, unsigned long *objno); -#endif /* H5TOOLS_UTILS_H__ */ +#endif /* H5TOOLS_UTILS_H__ */ |