2003-04-01 02:10:51 +08:00
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
* Copyright by The HDF Group. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-04-01 02:10:51 +08:00
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
|
|
|
* Programmer: Bill Wendling <wendling@ncsa.uiuc.edu>
|
|
|
|
* Monday, 19. February 2001
|
|
|
|
*
|
|
|
|
* Purpose: These are string functions for us to use and abuse.
|
|
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2001-02-25 06:25:15 +08:00
|
|
|
#include "H5private.h"
|
2006-01-24 04:46:34 +08:00
|
|
|
#include "h5tools.h" /*for h5tool_format_t structure */
|
2004-06-11 23:04:48 +08:00
|
|
|
#include "h5tools_ref.h"
|
2005-08-26 04:16:40 +08:00
|
|
|
#include "h5tools_str.h" /*function prototypes */
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2006-12-20 02:14:26 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
/*
|
|
|
|
* If REPEAT_VERBOSE is defined then character strings will be printed so
|
|
|
|
* that repeated character sequences like "AAAAAAAAAA" are displayed as
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* 'A' repeates 9 times
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
|
|
|
* Otherwise the format is more Perl-like
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* 'A'*10
|
2005-08-14 04:53:35 +08:00
|
|
|
*
|
2001-03-09 04:19:30 +08:00
|
|
|
*/
|
|
|
|
#define REPEAT_VERBOSE
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/* Variable length string datatype */
|
|
|
|
#define STR_INIT_LEN 4096 /*initial length */
|
|
|
|
|
2004-04-18 12:10:09 +08:00
|
|
|
static char *h5tools_escape(char *s, size_t size);
|
2001-03-09 04:19:30 +08:00
|
|
|
static hbool_t h5tools_is_zero(const void *_mem, size_t size);
|
2006-10-09 12:18:18 +08:00
|
|
|
static void h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_close
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Closes a string by releasing it's memory and setting the size
|
|
|
|
* information to zero.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: void
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_str_close(h5tools_str_t *str)
|
|
|
|
{
|
|
|
|
if (str && str->nalloc) {
|
2001-07-11 04:18:52 +08:00
|
|
|
free(str->s);
|
|
|
|
memset(str, 0, sizeof(h5tools_str_t));
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_len
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Returns the length of the string, not counting the null
|
|
|
|
* terminator.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: Length of string
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: 0
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
size_t
|
|
|
|
h5tools_str_len(h5tools_str_t *str)
|
|
|
|
{
|
|
|
|
return str->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_append
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Formats variable arguments according to printf() format
|
|
|
|
* string and appends the result to variable length string STR.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: Pointer to buffer containing result.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
2004-06-19 05:52:18 +08:00
|
|
|
* Major change: need to check results of vsnprintf to
|
|
|
|
* handle errors, empty format, and overflows.
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: REMcG Matzke
|
2004-06-19 05:52:18 +08:00
|
|
|
* June 16, 2004
|
|
|
|
*
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
h5tools_str_append(h5tools_str_t *str/*in,out*/, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
|
|
|
/* Make sure we have some memory into which to print */
|
|
|
|
if (!str->s || str->nalloc <= 0) {
|
2007-03-13 00:36:34 +08:00
|
|
|
str->nalloc = STR_INIT_LEN;
|
|
|
|
str->s = malloc(str->nalloc);
|
|
|
|
assert(str->s);
|
|
|
|
str->s[0] = '\0';
|
|
|
|
str->len = 0;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2004-06-19 05:52:18 +08:00
|
|
|
if (strlen(fmt) == 0) {
|
|
|
|
/* nothing to print */
|
|
|
|
va_end(ap);
|
|
|
|
return str->s;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2004-06-19 05:52:18 +08:00
|
|
|
/* Format the arguments and append to the value already in `str' */
|
|
|
|
while (1) {
|
|
|
|
/* How many bytes available for new value, counting the new NUL */
|
2007-03-13 00:36:34 +08:00
|
|
|
size_t avail = str->nalloc - str->len;
|
2004-06-19 05:52:18 +08:00
|
|
|
|
2007-03-13 00:36:34 +08:00
|
|
|
int nchars = HDvsnprintf(str->s + str->len, avail, fmt, ap);
|
2004-06-19 05:52:18 +08:00
|
|
|
|
2007-03-13 00:36:34 +08:00
|
|
|
if (nchars<0) {
|
2004-06-19 05:52:18 +08:00
|
|
|
/* failure, such as bad format */
|
|
|
|
va_end(ap);
|
2007-03-13 00:36:34 +08:00
|
|
|
return NULL;
|
2004-06-19 05:52:18 +08:00
|
|
|
}
|
|
|
|
|
2007-03-13 00:36:34 +08:00
|
|
|
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
|
2004-06-19 05:52:18 +08:00
|
|
|
* following conditions, each of which indicates that the proper C99 return value probably
|
2005-08-14 04:53:35 +08:00
|
|
|
* should have been positive when the format string is
|
2004-06-19 05:52:18 +08:00
|
|
|
* something other than "%s"
|
|
|
|
* Alocate at least twice as much space and try again.
|
|
|
|
*/
|
2007-03-13 00:36:34 +08:00
|
|
|
size_t newsize = MAX(str->len+nchars+1, 2*str->nalloc);
|
|
|
|
assert(newsize > str->nalloc); /*overflow*/
|
|
|
|
str->s = realloc(str->s, newsize);
|
|
|
|
assert(str->s);
|
|
|
|
str->nalloc = newsize;
|
|
|
|
} else {
|
|
|
|
/* Success */
|
|
|
|
str->len += nchars;
|
|
|
|
break;
|
2004-06-19 05:52:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
va_end(ap);
|
|
|
|
return str->s;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_reset
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Reset the string to the empty value. If no memory is
|
|
|
|
* allocated yet then initialize the h5tools_str_t struct.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: Ptr to the buffer which contains a null
|
|
|
|
* character as the first element.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
h5tools_str_reset(h5tools_str_t *str/*in,out*/)
|
|
|
|
{
|
|
|
|
if (!str->s || str->nalloc <= 0) {
|
2007-03-13 00:36:34 +08:00
|
|
|
str->nalloc = STR_INIT_LEN;
|
|
|
|
str->s = malloc(str->nalloc);
|
|
|
|
assert(str->s);
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
str->s[0] = '\0';
|
|
|
|
str->len = 0;
|
|
|
|
return str->s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_trunc
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Truncate a string to be at most SIZE characters.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: Pointer to the string
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
h5tools_str_trunc(h5tools_str_t *str/*in,out*/, size_t size)
|
|
|
|
{
|
|
|
|
if (size < str->len) {
|
2007-03-13 00:36:34 +08:00
|
|
|
str->len = size;
|
|
|
|
str->s[size] = '\0';
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return str->s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_fmt
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* 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>>".
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: A pointer to the resulting string.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
|
|
|
h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt)
|
|
|
|
{
|
|
|
|
char _temp[1024], *temp = _temp;
|
|
|
|
|
|
|
|
/* If the format string is simply "%s" then don't bother doing anything */
|
2001-07-11 04:18:52 +08:00
|
|
|
if (!strcmp(fmt, "%s"))
|
2001-02-23 05:55:15 +08:00
|
|
|
return str->s;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the input value if there is a `%' anywhere in FMT. Otherwise
|
|
|
|
* don't bother because we don't need a temporary copy.
|
|
|
|
*/
|
2001-07-11 04:18:52 +08:00
|
|
|
if (strchr(fmt, '%')) {
|
2001-02-23 05:55:15 +08:00
|
|
|
if (str->len - start + 1 > sizeof(_temp)) {
|
2001-07-11 04:18:52 +08:00
|
|
|
temp = malloc(str->len-start + 1);
|
2001-02-23 05:55:15 +08:00
|
|
|
assert(temp);
|
|
|
|
}
|
|
|
|
|
2001-07-11 04:18:52 +08:00
|
|
|
strcpy(temp, str->s + start);
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset the output string and append a formatted version */
|
|
|
|
h5tools_str_trunc(str, start);
|
|
|
|
h5tools_str_append(str, fmt, temp);
|
|
|
|
|
|
|
|
/* Free the temp buffer if we allocated one */
|
|
|
|
if (temp != _temp)
|
2001-07-11 04:18:52 +08:00
|
|
|
free(temp);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
return str->s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_prefix
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Renders the line prefix value into string STR.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: Pointer to the prefix.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-02-23 05:55:15 +08:00
|
|
|
* Thursday, July 23, 1998
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
2006-01-24 04:46:34 +08:00
|
|
|
h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info,
|
2007-09-13 23:44:56 +08:00
|
|
|
hsize_t elmtno, unsigned ndims, hsize_t min_idx[],
|
2005-02-09 04:55:17 +08:00
|
|
|
hsize_t max_idx[], h5tools_context_t *ctx)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2005-05-08 03:37:48 +08:00
|
|
|
hsize_t p_prod[H5S_MAX_RANK];
|
2007-03-27 11:06:48 +08:00
|
|
|
size_t i = 0;
|
2007-09-13 23:44:56 +08:00
|
|
|
hsize_t curr_pos = elmtno;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
h5tools_str_reset(str);
|
|
|
|
|
|
|
|
if (ndims > 0) {
|
|
|
|
/*
|
|
|
|
* Calculate the number of elements represented by a unit change in a
|
|
|
|
* certain index position.
|
|
|
|
*/
|
|
|
|
for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i)
|
|
|
|
p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i];
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
for ( i = 0; i < (size_t)ndims; i++) {
|
|
|
|
ctx->pos[i] = curr_pos/ctx->acc[i];
|
|
|
|
curr_pos -= ctx->acc[i]*ctx->pos[i];
|
2005-02-09 04:55:17 +08:00
|
|
|
}
|
|
|
|
assert( curr_pos == 0 );
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/* Print the index values */
|
2007-03-27 11:06:48 +08:00
|
|
|
for (i = 0; i < (size_t)ndims; i++) {
|
2001-02-23 05:55:15 +08:00
|
|
|
if (i)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->idx_sep, ","));
|
|
|
|
|
2006-12-20 02:14:26 +08:00
|
|
|
h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT),
|
|
|
|
(hsize_t)ctx->pos[i]);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Scalar */
|
2006-12-20 02:14:26 +08:00
|
|
|
h5tools_str_append(str, OPT(info->idx_n_fmt, HSIZE_T_FORMAT), (hsize_t)0);
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Add prefix and suffix to the index */
|
|
|
|
return h5tools_str_fmt(str, 0, OPT(info->idx_fmt, "%s: "));
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_dump_region
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Prints information about a dataspace region by appending
|
|
|
|
* the information to the specified string.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: 0
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-03-09 04:19:30 +08:00
|
|
|
* Monday, June 7, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2006-01-24 04:46:34 +08:00
|
|
|
h5tools_str_dump_region(h5tools_str_t *str, hid_t region, const h5tool_format_t *info)
|
2001-03-09 04:19:30 +08:00
|
|
|
{
|
2007-03-13 00:36:34 +08:00
|
|
|
hssize_t nblocks, npoints;
|
2001-03-09 04:19:30 +08:00
|
|
|
hsize_t alloc_size;
|
|
|
|
hsize_t *ptdata;
|
2007-03-13 00:36:34 +08:00
|
|
|
int ndims = H5Sget_simple_extent_ndims(region);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* These two functions fail if the region does not have blocks or points,
|
|
|
|
* respectively. They do not currently know how to translate from one to
|
|
|
|
* the other.
|
|
|
|
*/
|
|
|
|
H5E_BEGIN_TRY {
|
|
|
|
nblocks = H5Sget_select_hyper_nblocks(region);
|
|
|
|
npoints = H5Sget_select_elem_npoints(region);
|
|
|
|
} H5E_END_TRY;
|
|
|
|
|
|
|
|
h5tools_str_append(str, "{");
|
|
|
|
|
|
|
|
/* Print block information */
|
|
|
|
if (nblocks > 0) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
|
|
|
|
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
|
2001-07-11 04:18:52 +08:00
|
|
|
ptdata = malloc((size_t)alloc_size);
|
2001-03-09 04:19:30 +08:00
|
|
|
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
|
|
|
|
H5Sget_select_hyper_blocklist(region, (hsize_t)0, (hsize_t)nblocks, ptdata);
|
|
|
|
|
|
|
|
for (i = 0; i < nblocks; i++) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
h5tools_str_append(str, info->dset_blockformat_pre,
|
|
|
|
i ? "," OPTIONAL_LINE_BREAK " " : "",
|
|
|
|
(unsigned long)i);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
/* Start coordinates and opposite corner */
|
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
h5tools_str_append(str, "%s%lu", j ? "," : "(",
|
|
|
|
(unsigned long)ptdata[i * 2 * ndims + j]);
|
|
|
|
|
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
h5tools_str_append(str, "%s%lu", j ? "," : ")-(",
|
|
|
|
(unsigned long)ptdata[i * 2 * ndims + j + ndims]);
|
|
|
|
|
|
|
|
h5tools_str_append(str, ")");
|
|
|
|
}
|
|
|
|
|
2001-07-11 04:18:52 +08:00
|
|
|
free(ptdata);
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Print point information */
|
|
|
|
if (npoints > 0) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
alloc_size = npoints * ndims * sizeof(ptdata[0]);
|
|
|
|
assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/
|
2001-07-11 04:18:52 +08:00
|
|
|
ptdata = malloc((size_t)alloc_size);
|
2001-03-09 04:19:30 +08:00
|
|
|
H5_CHECK_OVERFLOW(npoints,hssize_t,hsize_t);
|
|
|
|
H5Sget_select_elem_pointlist(region, (hsize_t)0, (hsize_t)npoints, ptdata);
|
|
|
|
|
|
|
|
for (i = 0; i < npoints; i++) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
h5tools_str_append(str, info->dset_ptformat_pre ,
|
|
|
|
i ? "," OPTIONAL_LINE_BREAK " " : "",
|
|
|
|
(unsigned long)i);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
for (j = 0; j < ndims; j++)
|
|
|
|
h5tools_str_append(str, "%s%lu", j ? "," : "(",
|
|
|
|
(unsigned long)(ptdata[i * ndims + j]));
|
|
|
|
|
|
|
|
h5tools_str_append(str, ")");
|
|
|
|
}
|
|
|
|
|
2001-07-11 04:18:52 +08:00
|
|
|
free(ptdata);
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, "}");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_print_char
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Shove a character into the STR.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Nothing
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Bill Wendling
|
2001-03-09 04:19:30 +08:00
|
|
|
* Tuesday, 20. February 2001
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2006-10-09 12:18:18 +08:00
|
|
|
static void
|
|
|
|
h5tools_print_char(h5tools_str_t *str, const h5tool_format_t *info, char ch)
|
2001-03-09 04:19:30 +08:00
|
|
|
{
|
|
|
|
if (info->str_locale == ESCAPE_HTML) {
|
|
|
|
if (ch <= ' ' || ch > '~')
|
|
|
|
h5tools_str_append(str, "%%%02x", ch);
|
|
|
|
else
|
2006-10-09 12:18:18 +08:00
|
|
|
h5tools_str_append(str, "%c", ch);
|
2001-03-09 04:19:30 +08:00
|
|
|
} else {
|
|
|
|
switch (ch) {
|
2006-10-09 12:18:18 +08:00
|
|
|
case '"':
|
|
|
|
if (!info->do_escape)
|
|
|
|
h5tools_str_append(str, "\"");
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\\"");
|
|
|
|
break;
|
|
|
|
case '\\':
|
|
|
|
if (!info->do_escape)
|
|
|
|
h5tools_str_append(str, "\\");
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\\\");
|
|
|
|
break;
|
|
|
|
case '\b':
|
|
|
|
if (!info->do_escape)
|
|
|
|
h5tools_str_append(str, "\b");
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\b");
|
|
|
|
break;
|
|
|
|
case '\f':
|
|
|
|
if (!info->do_escape)
|
|
|
|
h5tools_str_append(str, "\f");
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\f");
|
|
|
|
break;
|
|
|
|
case '\n':
|
|
|
|
if (!info->do_escape) {
|
|
|
|
h5tools_str_append(str, "\n");
|
|
|
|
h5tools_str_append(str, " ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\n");
|
|
|
|
break;
|
|
|
|
case '\r':
|
|
|
|
if (!info->do_escape) {
|
|
|
|
h5tools_str_append(str, "\r");
|
|
|
|
h5tools_str_append(str, " ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\r");
|
|
|
|
break;
|
|
|
|
case '\t':
|
|
|
|
if (!info->do_escape)
|
|
|
|
h5tools_str_append(str, "\t");
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\t");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (isprint(ch))
|
|
|
|
h5tools_str_append(str, "%c", ch);
|
|
|
|
else
|
|
|
|
h5tools_str_append(str, "\\%03o", ch);
|
|
|
|
|
|
|
|
break;
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-22 22:29:21 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_str_sprint
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Renders the value pointed to by VP of type TYPE into variable
|
|
|
|
* length string STR.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: A pointer to memory containing the result or NULL on error.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-03-09 04:19:30 +08:00
|
|
|
* Thursday, July 23, 1998
|
|
|
|
*
|
|
|
|
* Modifications:
|
2007-03-13 00:36:34 +08:00
|
|
|
* Robb Matzke, 1999-04-26
|
|
|
|
* Made this function safe from overflow problems by allowing it
|
|
|
|
* to reallocate the output string.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Robb Matzke, 1999-06-04
|
|
|
|
* Added support for object references. The new `container'
|
|
|
|
* argument is the dataset where the reference came from.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Robb Matzke, 1999-06-07
|
|
|
|
* Added support for printing raw data. If info->raw is non-zero
|
|
|
|
* then data is printed in hexadecimal format.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2006-03-29 05:25:10 +08:00
|
|
|
* Robb Matzke, 2003-01-10
|
|
|
|
* Binary output format is dd:dd:... instead of 0xdddd... so it
|
|
|
|
* doesn't look like a hexadecimal integer, and thus users will
|
|
|
|
* be less likely to complain that HDF5 didn't properly byte
|
|
|
|
* swap their data during type conversion.
|
|
|
|
*
|
|
|
|
* Robb Matzke, LLNL, 2003-06-05
|
|
|
|
* If TYPE is a variable length string then the pointer to
|
|
|
|
* the value to pring (VP) is a pointer to a `char*'.
|
|
|
|
*
|
2007-03-13 03:24:38 +08:00
|
|
|
* PVN, 28 March 2006
|
2006-03-29 05:25:10 +08:00
|
|
|
* added H5T_NATIVE_LDOUBLE case
|
2001-03-09 04:19:30 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
char *
|
2006-01-24 04:46:34 +08:00
|
|
|
h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container,
|
2001-03-09 04:19:30 +08:00
|
|
|
hid_t type, void *vp, h5tools_context_t *ctx)
|
|
|
|
{
|
2003-11-13 23:19:50 +08:00
|
|
|
size_t n, offset, size=0, nelmts, start;
|
|
|
|
char *name;
|
2001-03-09 04:19:30 +08:00
|
|
|
unsigned char *ucp_vp = (unsigned char *)vp;
|
|
|
|
char *cp_vp = (char *)vp;
|
|
|
|
hid_t memb, obj, region;
|
2003-10-14 03:31:33 +08:00
|
|
|
unsigned nmembs;
|
2001-03-09 04:19:30 +08:00
|
|
|
static char fmt_llong[8], fmt_ullong[8];
|
|
|
|
H5T_str_t pad;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* some tempvars to store the value before we append it to the string to
|
|
|
|
* get rid of the memory alignment problem
|
|
|
|
*/
|
|
|
|
unsigned long_long tempullong;
|
|
|
|
long_long templlong;
|
|
|
|
unsigned long tempulong;
|
|
|
|
long templong;
|
|
|
|
unsigned int tempuint;
|
|
|
|
int tempint;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
/* Build default formats for long long types */
|
2007-09-13 23:44:56 +08:00
|
|
|
if(!fmt_llong[0]) {
|
2002-04-28 16:34:17 +08:00
|
|
|
sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH);
|
|
|
|
sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH);
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Append value depending on data type */
|
|
|
|
start = h5tools_str_len(str);
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
if(info->raw) {
|
2001-03-09 04:19:30 +08:00
|
|
|
size_t i;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
n = H5Tget_size(type);
|
2003-06-10 03:29:28 +08:00
|
|
|
if (1==n) {
|
|
|
|
h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]);
|
|
|
|
} else {
|
2007-09-13 23:44:56 +08:00
|
|
|
for(i = 0; i < n; i++) {
|
|
|
|
if(i)
|
|
|
|
h5tools_str_append(str, ":");
|
|
|
|
h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]);
|
2003-06-10 03:29:28 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_FLOAT)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
float tempfloat;
|
|
|
|
|
|
|
|
HDmemcpy(&tempfloat, vp, sizeof(float));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
double tempdouble;
|
|
|
|
|
|
|
|
HDmemcpy(&tempdouble, vp, sizeof(double));
|
|
|
|
h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble);
|
2006-03-29 05:25:10 +08:00
|
|
|
#if H5_SIZEOF_LONG_DOUBLE !=0
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
long double templdouble;
|
|
|
|
|
|
|
|
HDmemcpy(&templdouble, vp, sizeof(long double));
|
|
|
|
h5tools_str_append(str, "%Lf", templdouble);
|
2006-03-29 05:25:10 +08:00
|
|
|
#endif
|
2007-09-13 23:44:56 +08:00
|
|
|
} else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) ||
|
2001-03-09 04:19:30 +08:00
|
|
|
H5Tequal(type, H5T_NATIVE_UCHAR))) {
|
2006-10-09 12:18:18 +08:00
|
|
|
h5tools_print_char(str, info, (char)(*ucp_vp));
|
2001-03-09 04:19:30 +08:00
|
|
|
} else if (H5T_STRING == H5Tget_class(type)) {
|
|
|
|
unsigned int i;
|
2003-11-13 23:19:50 +08:00
|
|
|
char quote = '\0';
|
2003-06-10 03:29:28 +08:00
|
|
|
char *s;
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
quote = '\0';
|
2002-11-19 00:38:11 +08:00
|
|
|
if(H5Tis_variable_str(type)) {
|
2003-06-10 03:29:28 +08:00
|
|
|
/* cp_vp is the pointer into the struct where a `char*' is stored. So we have
|
|
|
|
* to dereference the pointer to get the `char*' to pass to HDstrlen(). */
|
|
|
|
s = *(char**)cp_vp;
|
2003-11-13 23:19:50 +08:00
|
|
|
if(s!=NULL)
|
|
|
|
size = HDstrlen(s);
|
2002-11-19 00:38:11 +08:00
|
|
|
} else {
|
2003-06-10 03:29:28 +08:00
|
|
|
s = cp_vp;
|
2002-11-19 00:38:11 +08:00
|
|
|
size = H5Tget_size(type);
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
pad = H5Tget_strpad(type);
|
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
/* Check for NULL pointer for string */
|
|
|
|
if(s==NULL) {
|
|
|
|
h5tools_str_append(str, "NULL");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (i=0; i<size && (s[i] || pad!=H5T_STR_NULLTERM); i++) {
|
|
|
|
int j = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Count how many times the next character repeats. If the
|
|
|
|
* threshold is zero then that means it can repeat any number
|
|
|
|
* of times.
|
|
|
|
*/
|
|
|
|
if (info->str_repeat > 0)
|
|
|
|
while (i + j < size && s[i] == s[i + j])
|
|
|
|
j++;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
/*
|
|
|
|
* Print the opening quote. If the repeat count is high enough to
|
|
|
|
* warrant printing the number of repeats instead of enumerating
|
|
|
|
* the characters, then make sure the character to be repeated is
|
|
|
|
* in it's own quote.
|
|
|
|
*/
|
|
|
|
if (info->str_repeat > 0 && j > info->str_repeat) {
|
|
|
|
if (quote)
|
|
|
|
h5tools_str_append(str, "%c", quote);
|
|
|
|
|
|
|
|
quote = '\'';
|
|
|
|
h5tools_str_append(str, "%s%c", i ? " " : "", quote);
|
|
|
|
} else if (!quote) {
|
|
|
|
quote = '"';
|
|
|
|
h5tools_str_append(str, "%s%c", i ? " " : "", quote);
|
|
|
|
}
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
/* Print the character */
|
2006-10-09 12:18:18 +08:00
|
|
|
h5tools_print_char(str, info, s[i]);
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
/* Print the repeat count */
|
|
|
|
if (info->str_repeat && j > info->str_repeat) {
|
2001-03-09 04:19:30 +08:00
|
|
|
#ifdef REPEAT_VERBOSE
|
2003-11-13 23:19:50 +08:00
|
|
|
h5tools_str_append(str, "%c repeats %d times", quote, j - 1);
|
2001-03-09 04:19:30 +08:00
|
|
|
#else
|
2003-11-13 23:19:50 +08:00
|
|
|
h5tools_str_append(str, "%c*%d", quote, j - 1);
|
2001-03-09 04:19:30 +08:00
|
|
|
#endif /* REPEAT_VERBOSE */
|
2003-11-13 23:19:50 +08:00
|
|
|
quote = '\0';
|
|
|
|
i += j - 1;
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
if (quote)
|
|
|
|
h5tools_str_append(str, "%c", quote);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
2003-11-13 23:19:50 +08:00
|
|
|
if (i == 0)
|
|
|
|
/*empty string*/
|
|
|
|
h5tools_str_append(str, "\"\"");
|
|
|
|
} /* end else */
|
2001-03-09 04:19:30 +08:00
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_INT)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemcpy(&tempint, vp, sizeof(int));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_UINT)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemcpy(&tempuint, vp, sizeof(unsigned int));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_SCHAR)) {
|
|
|
|
h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_UCHAR)) {
|
|
|
|
h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_SHORT)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
short tempshort;
|
|
|
|
|
|
|
|
HDmemcpy(&tempshort, vp, sizeof(short));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_USHORT)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
unsigned short tempushort;
|
|
|
|
|
|
|
|
HDmemcpy(&tempushort, vp, sizeof(unsigned short));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_LONG)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemcpy(&templong, vp, sizeof(long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_ULONG)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemcpy(&tempulong, vp, sizeof(unsigned long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_LLONG)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemcpy(&templlong, vp, sizeof(long_long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_ULLONG)) {
|
2007-09-13 23:44:56 +08:00
|
|
|
HDmemcpy(&tempullong, vp, sizeof(unsigned long_long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) {
|
|
|
|
if (sizeof(hssize_t) == sizeof(int)) {
|
2005-08-14 04:53:35 +08:00
|
|
|
memcpy(&tempint, vp, sizeof(int));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint);
|
|
|
|
} else if (sizeof(hssize_t) == sizeof(long)) {
|
2001-07-11 04:18:52 +08:00
|
|
|
memcpy(&templong, vp, sizeof(long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong);
|
|
|
|
} else {
|
2001-07-11 04:18:52 +08:00
|
|
|
memcpy(&templlong, vp, sizeof(long_long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong);
|
|
|
|
}
|
|
|
|
} else if (H5Tequal(type, H5T_NATIVE_HSIZE)) {
|
|
|
|
if (sizeof(hsize_t) == sizeof(int)) {
|
2001-07-11 04:18:52 +08:00
|
|
|
memcpy(&tempuint, vp, sizeof(unsigned int));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint);
|
|
|
|
} else if (sizeof(hsize_t) == sizeof(long)) {
|
2001-07-11 04:18:52 +08:00
|
|
|
memcpy(&tempulong, vp, sizeof(long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong);
|
|
|
|
} else {
|
2001-07-11 04:18:52 +08:00
|
|
|
memcpy(&tempullong, vp, sizeof(unsigned long_long));
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong);
|
|
|
|
}
|
|
|
|
} else if (H5Tget_class(type) == H5T_COMPOUND) {
|
2003-10-14 03:31:33 +08:00
|
|
|
unsigned j;
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
nmembs = H5Tget_nmembers(type);
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->cmpd_pre, "{"));
|
|
|
|
|
|
|
|
for (j = 0; j < nmembs; j++) {
|
|
|
|
if (j)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->cmpd_sep, ", " OPTIONAL_LINE_BREAK));
|
|
|
|
|
|
|
|
/* RPM 2000-10-31
|
|
|
|
* If the previous character is a line-feed (which is true when
|
|
|
|
* h5dump is running) then insert some white space for
|
|
|
|
* indentation. Be warned that column number calculations will be
|
|
|
|
* incorrect and that object indices at the beginning of the line
|
|
|
|
* will be missing (h5dump doesn't display them anyway). */
|
|
|
|
if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') {
|
|
|
|
int x;
|
|
|
|
|
|
|
|
h5tools_str_append(str, OPT(info->line_pre, ""), "");
|
|
|
|
|
|
|
|
for (x = 0; x < ctx->indent_level + 1; x++)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->line_indent, ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The name */
|
|
|
|
name = H5Tget_member_name(type, j);
|
|
|
|
h5tools_str_append(str, OPT(info->cmpd_name, ""), name);
|
2001-07-11 04:18:52 +08:00
|
|
|
free(name);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
/* The value */
|
|
|
|
offset = H5Tget_member_offset(type, j);
|
|
|
|
memb = H5Tget_member_type(type, j);
|
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
h5tools_str_sprint(str, info, container, memb, cp_vp + offset , ctx);
|
|
|
|
ctx->indent_level--;
|
|
|
|
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* RPM 2000-10-31
|
|
|
|
* If the previous character is a line feed (which is true when
|
|
|
|
* h5dump is running) then insert some white space for indentation.
|
|
|
|
* Be warned that column number calculations will be incorrect and
|
|
|
|
* that object indices at the beginning of the line will be missing
|
|
|
|
* (h5dump doesn't display them anyway). */
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->cmpd_end, ""));
|
|
|
|
|
|
|
|
if (ctx->indent_level >= 0 && str->len && str->s[str->len - 1] == '\n') {
|
|
|
|
int x;
|
|
|
|
|
|
|
|
h5tools_str_append(str, OPT(info->line_pre, ""), "");
|
|
|
|
|
|
|
|
for (x = 0; x < ctx->indent_level; x++)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->line_indent, ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->cmpd_suf, "}"));
|
|
|
|
} else if (H5Tget_class(type) == H5T_ENUM) {
|
|
|
|
char enum_name[1024];
|
|
|
|
|
|
|
|
if (H5Tenum_nameof(type, vp, enum_name, sizeof enum_name) >= 0) {
|
2004-04-18 12:10:09 +08:00
|
|
|
h5tools_str_append(str, h5tools_escape(enum_name, sizeof(enum_name)));
|
2001-03-09 04:19:30 +08:00
|
|
|
} else {
|
|
|
|
size_t i;
|
|
|
|
n = H5Tget_size(type);
|
2003-06-10 03:29:28 +08:00
|
|
|
if (1==n) {
|
|
|
|
h5tools_str_append(str, "0x%02x", ucp_vp[0]);
|
|
|
|
} else {
|
2001-03-09 04:19:30 +08:00
|
|
|
for (i = 0; i < n; i++)
|
2003-06-10 03:29:28 +08:00
|
|
|
h5tools_str_append(str, "%s%02x", i?":":"", ucp_vp[i]);
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
|
|
|
} else if (H5Tequal(type, H5T_STD_REF_DSETREG)) {
|
|
|
|
/*
|
|
|
|
* Dataset region reference -- show the type and OID of the referenced
|
|
|
|
* object, but we are unable to show the region yet because there
|
|
|
|
* isn't enough support in the data space layer. - rpm 19990604
|
|
|
|
*/
|
|
|
|
if (h5tools_is_zero(vp, H5Tget_size(type))) {
|
|
|
|
h5tools_str_append(str, "NULL");
|
|
|
|
} else {
|
2007-08-31 04:03:37 +08:00
|
|
|
char ref_name[1024];
|
2006-04-15 06:21:54 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
obj = H5Rdereference(container, H5R_DATASET_REGION, vp);
|
|
|
|
region = H5Rget_region(container, H5R_DATASET_REGION, vp);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2007-01-11 00:24:27 +08:00
|
|
|
/* get name of the dataset the region reference points to using H5Rget_name */
|
2007-08-31 04:03:37 +08:00
|
|
|
H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*)ref_name, 1024);
|
|
|
|
h5tools_str_append(str, info->dset_format, ref_name);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
h5tools_str_dump_region(str, region, info);
|
|
|
|
H5Sclose(region);
|
|
|
|
H5Dclose(obj);
|
|
|
|
}
|
|
|
|
} else if (H5Tequal(type, H5T_STD_REF_OBJ)) {
|
|
|
|
/*
|
|
|
|
* Object references -- show the type and OID of the referenced
|
|
|
|
* object.
|
|
|
|
*/
|
|
|
|
if (h5tools_is_zero(vp, H5Tget_size(type))) {
|
|
|
|
h5tools_str_append(str, "NULL");
|
|
|
|
} else {
|
2007-09-13 23:44:56 +08:00
|
|
|
H5O_info_t oi;
|
2005-08-26 04:16:40 +08:00
|
|
|
const char *path;
|
2006-04-15 06:21:54 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
obj = H5Rdereference(container, H5R_OBJECT, vp);
|
[svn-r14225] Description:
Change H5Oget_info -> H5Oget_info_by_name and re-add H5Oget_info in a
simpler form for querying a particular object, to align with other new API
routines.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-31 21:13:40 +08:00
|
|
|
H5Oget_info(obj, &oi);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
/* Print object type and close object */
|
2007-09-13 23:44:56 +08:00
|
|
|
switch(oi.type) {
|
|
|
|
case H5O_TYPE_GROUP:
|
2007-06-19 04:03:30 +08:00
|
|
|
h5tools_str_append(str, H5_TOOLS_GROUP);
|
2001-03-09 04:19:30 +08:00
|
|
|
break;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
|
|
case H5O_TYPE_DATASET:
|
2007-06-19 04:03:30 +08:00
|
|
|
h5tools_str_append(str, H5_TOOLS_DATASET);
|
2001-03-09 04:19:30 +08:00
|
|
|
break;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
|
|
case H5O_TYPE_NAMED_DATATYPE:
|
2007-06-19 04:03:30 +08:00
|
|
|
h5tools_str_append(str, H5_TOOLS_DATATYPE);
|
2001-03-09 04:19:30 +08:00
|
|
|
break;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
default:
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_str_append(str, "%u-", (unsigned)oi.type);
|
2001-03-09 04:19:30 +08:00
|
|
|
break;
|
2007-09-13 23:44:56 +08:00
|
|
|
} /* end switch */
|
|
|
|
H5Oclose(obj);
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
/* Print OID */
|
2007-09-13 23:44:56 +08:00
|
|
|
if(info->obj_hidefileno)
|
|
|
|
h5tools_str_append(str, info->obj_format, oi.addr);
|
2003-08-09 03:39:10 +08:00
|
|
|
else
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
|
2004-06-11 01:35:48 +08:00
|
|
|
|
|
|
|
/* Print name */
|
2005-08-26 04:16:40 +08:00
|
|
|
path = lookup_ref_path(*(haddr_t *)vp);
|
2004-06-11 01:35:48 +08:00
|
|
|
if (path) {
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_str_append(str, " ");
|
|
|
|
h5tools_str_append(str, path);
|
|
|
|
h5tools_str_append(str, " ");
|
|
|
|
} /* end if */
|
|
|
|
} /* end else */
|
2001-03-09 04:19:30 +08:00
|
|
|
} else if (H5Tget_class(type) == H5T_ARRAY) {
|
|
|
|
int k, ndims;
|
2007-03-13 00:36:34 +08:00
|
|
|
hsize_t i, dims[H5S_MAX_RANK],temp_nelmts;
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
/* Get the array's base datatype for each element */
|
|
|
|
memb = H5Tget_super(type);
|
|
|
|
size = H5Tget_size(memb);
|
|
|
|
ndims = H5Tget_array_ndims(type);
|
[svn-r14212] Description:
Make H5Tarray_create() and H5Tget_array_dims() versioned, and drop the
"perm" parameter from the '2' versions.
Shift internal library usage to '2' versions.
Add simple regression tests for '1' versions.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
2007-10-19 06:02:19 +08:00
|
|
|
H5Tget_array_dims2(type, dims);
|
2001-03-09 04:19:30 +08:00
|
|
|
assert(ndims >= 1 && ndims <= H5S_MAX_RANK);
|
|
|
|
|
|
|
|
/* Calculate the number of array elements */
|
2001-11-28 00:29:13 +08:00
|
|
|
for (k = 0, nelmts = 1; k < ndims; k++){
|
2007-03-13 00:36:34 +08:00
|
|
|
temp_nelmts = nelmts;
|
|
|
|
temp_nelmts *= dims[k];
|
|
|
|
assert(temp_nelmts==(hsize_t)((size_t)temp_nelmts));
|
2001-11-28 00:29:13 +08:00
|
|
|
nelmts = (size_t)temp_nelmts;
|
2007-03-13 00:36:34 +08:00
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
/* Print the opening bracket */
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->arr_pre, "["));
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
for(i = 0; i < nelmts; i++) {
|
|
|
|
if(i)
|
2001-03-09 04:19:30 +08:00
|
|
|
h5tools_str_append(str, "%s",
|
|
|
|
OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK));
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
if(info->arr_linebreak && i && i % dims[ndims - 1] == 0) {
|
2001-03-09 04:19:30 +08:00
|
|
|
int x;
|
|
|
|
|
|
|
|
h5tools_str_append(str, "%s", "\n");
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
/* need to indent some more here*/
|
|
|
|
if(ctx->indent_level >= 0)
|
|
|
|
if(!info->pindex)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
|
2004-06-30 01:42:09 +08:00
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
for(x = 0; x < ctx->indent_level + 1; x++)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->line_indent, ""));
|
2001-03-09 04:19:30 +08:00
|
|
|
} /* end if */
|
2003-10-06 05:20:33 +08:00
|
|
|
else if(i && info->arr_sep)
|
|
|
|
h5tools_str_append(str, " ");
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
|
|
|
|
/* Dump the array element */
|
|
|
|
h5tools_str_sprint(str, info, container, memb, cp_vp + i * size, ctx);
|
|
|
|
|
|
|
|
ctx->indent_level--;
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
/* Print the closing bracket */
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_str_append(str, "%s", OPT(info->arr_suf, "]"));
|
2001-03-09 04:19:30 +08:00
|
|
|
H5Tclose(memb);
|
|
|
|
} else if (H5Tget_class(type) == H5T_VLEN) {
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
/* Get the VL sequences's base datatype for each element */
|
|
|
|
memb = H5Tget_super(type);
|
|
|
|
size = H5Tget_size(memb);
|
|
|
|
|
|
|
|
/* Print the opening bracket */
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->vlen_pre, "("));
|
|
|
|
|
|
|
|
/* Get the number of sequence elements */
|
|
|
|
nelmts = ((hvl_t *)cp_vp)->len;
|
|
|
|
|
|
|
|
for (i = 0; i < nelmts; i++) {
|
|
|
|
if (i)
|
|
|
|
h5tools_str_append(str, "%s",
|
2003-10-06 05:20:33 +08:00
|
|
|
OPT(info->vlen_sep, "," OPTIONAL_LINE_BREAK));
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
#ifdef LATER
|
|
|
|
/* Need to fix so VL data breaks at correct location on end of line -QAK */
|
|
|
|
if (info->arr_linebreak && h5tools_str_len(str)>=info->line_ncols) {
|
|
|
|
int x;
|
|
|
|
|
|
|
|
h5tools_str_append(str, "%s", "\n");
|
|
|
|
|
|
|
|
/* need to indent some more here */
|
|
|
|
if (ctx->indent_level >= 0)
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->line_pre, ""));
|
|
|
|
|
|
|
|
for (x = 0; x < ctx->indent_level + 1; x++)
|
|
|
|
h5tools_str_append(str,"%s",OPT(info->line_indent,""));
|
|
|
|
} /* end if */
|
|
|
|
#endif /* LATER */
|
|
|
|
|
|
|
|
ctx->indent_level++;
|
|
|
|
|
|
|
|
/* Dump the array element */
|
|
|
|
h5tools_str_sprint(str, info, container, memb,
|
|
|
|
((char *)(((hvl_t *)cp_vp)->p)) + i * size, ctx);
|
|
|
|
|
|
|
|
ctx->indent_level--;
|
|
|
|
} /* end for */
|
|
|
|
|
|
|
|
h5tools_str_append(str, "%s", OPT(info->vlen_suf, ")"));
|
|
|
|
H5Tclose(memb);
|
|
|
|
} else {
|
|
|
|
/* All other types get printed as hexadecimal */
|
|
|
|
size_t i;
|
|
|
|
n = H5Tget_size(type);
|
2003-06-10 03:29:28 +08:00
|
|
|
if (1==n) {
|
|
|
|
h5tools_str_append(str, "0x%02x", ucp_vp[0]);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
h5tools_str_append(str, "%s%02x", i?":":"", ucp_vp[i]);
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_escape
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Changes all "funny" characters in S into standard C escape
|
|
|
|
* sequences.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: Success: S
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Failure: NULL if the buffer would overflow. The
|
|
|
|
* buffer has as many left-to-right escapes as
|
|
|
|
* possible before overflow would have happened.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-03-09 04:19:30 +08:00
|
|
|
* Monday, April 26, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static char *
|
2004-04-18 12:10:09 +08:00
|
|
|
h5tools_escape(char *s/*in,out*/, size_t size)
|
2001-03-09 04:19:30 +08:00
|
|
|
{
|
|
|
|
register size_t i;
|
|
|
|
size_t n = strlen(s);
|
|
|
|
const char *escape;
|
|
|
|
char octal[8];
|
2004-01-16 00:42:22 +08:00
|
|
|
|
2001-03-09 04:19:30 +08:00
|
|
|
for (i = 0; i < n; i++) {
|
2007-03-13 00:36:34 +08:00
|
|
|
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 */
|
|
|
|
}
|
2001-03-09 04:19:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
* Function: h5tools_is_zero
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Purpose: Determines if memory is initialized to all zero bytes.
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Return: TRUE if all bytes are zero; FALSE otherwise
|
2001-03-09 04:19:30 +08:00
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
* Programmer: Robb Matzke
|
2001-03-09 04:19:30 +08:00
|
|
|
* Monday, June 7, 1999
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static hbool_t
|
|
|
|
h5tools_is_zero(const void *_mem, size_t size)
|
|
|
|
{
|
|
|
|
const unsigned char *mem = (const unsigned char *)_mem;
|
|
|
|
|
|
|
|
while (size-- > 0)
|
2007-03-13 00:36:34 +08:00
|
|
|
if (mem[size])
|
|
|
|
return FALSE;
|
2001-03-09 04:19:30 +08:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|