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: Robb Matzke <matzke@llnl.gov>
|
|
|
|
* Thursday, July 23, 1998
|
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: A library for displaying the values of a dataset in a human
|
|
|
|
* readable format.
|
2001-02-23 05:55:15 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "h5tools.h"
|
2012-02-18 05:41:58 +08:00
|
|
|
#include "h5tools_dump.h"
|
2005-08-26 04:16:40 +08:00
|
|
|
#include "h5tools_ref.h"
|
2001-03-09 04:21:05 +08:00
|
|
|
#include "h5tools_utils.h"
|
2001-02-23 05:55:15 +08:00
|
|
|
#include "H5private.h"
|
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* global variables */
|
2012-03-13 00:33:15 +08:00
|
|
|
hid_t H5tools_ERR_STACK_g = 0;
|
2009-09-15 03:52:42 +08:00
|
|
|
hid_t H5tools_ERR_CLS_g = -1;
|
|
|
|
hid_t H5E_tools_g = -1;
|
|
|
|
hid_t H5E_tools_min_id_g = -1;
|
2001-03-09 04:21:05 +08:00
|
|
|
int compound_data;
|
2013-07-31 01:04:23 +08:00
|
|
|
FILE *rawattrstream = NULL; /* should initialize to stdout but gcc moans about it */
|
|
|
|
FILE *rawdatastream = NULL; /* should initialize to stdout but gcc moans about it */
|
|
|
|
FILE *rawinstream = NULL; /* should initialize to stdin but gcc moans about it */
|
|
|
|
FILE *rawoutstream = NULL; /* should initialize to stdout but gcc moans about it */
|
|
|
|
FILE *rawerrorstream = NULL; /* should initialize to stderr but gcc moans about it */
|
2012-02-18 05:41:58 +08:00
|
|
|
int bin_output; /* binary output */
|
|
|
|
int bin_form; /* binary form */
|
|
|
|
int region_output; /* region output */
|
|
|
|
int oid_output; /* oid output */
|
|
|
|
int data_output; /* data output */
|
|
|
|
int attr_data_output; /* attribute data output */
|
|
|
|
int packed_bits_num; /* number of packed bits to display */
|
2011-04-30 02:38:41 +08:00
|
|
|
int packed_data_offset; /* offset of packed bits to display */
|
2012-02-18 05:41:58 +08:00
|
|
|
int packed_data_length; /* lengtht of packed bits to display */
|
2011-04-30 02:38:41 +08:00
|
|
|
unsigned long long packed_data_mask; /* mask in which packed bits to display */
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/* module-scoped variables */
|
2001-03-09 04:21:05 +08:00
|
|
|
static int h5tools_init_g; /* if h5tools lib has been initialized */
|
2004-02-05 06:43:00 +08:00
|
|
|
|
|
|
|
/* Names of VFDs */
|
|
|
|
static const char *drivernames[]={
|
|
|
|
"sec2",
|
|
|
|
"family",
|
|
|
|
"split",
|
|
|
|
"multi",
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
"mpio",
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This enum should match the entries in the above drivers_list since they
|
|
|
|
* are indexes into the drivers_list array. */
|
2013-08-15 21:24:28 +08:00
|
|
|
typedef enum {
|
2004-02-05 06:43:00 +08:00
|
|
|
SEC2_IDX = 0
|
|
|
|
,FAMILY_IDX
|
|
|
|
,SPLIT_IDX
|
|
|
|
,MULTI_IDX
|
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
,MPIO_IDX
|
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
} driver_idx;
|
|
|
|
#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
|
2001-02-23 05:55:15 +08:00
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Initialize the H5 Tools library
|
|
|
|
* Description:
|
|
|
|
* This should be called before any other h5tools function is called.
|
|
|
|
* Effect of any h5tools function called before this has been called is
|
|
|
|
* undetermined.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Albert Cheng, 2000-10-31
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_init(void)
|
|
|
|
{
|
2009-09-15 03:52:42 +08:00
|
|
|
char lib_str[256];
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
if (!h5tools_init_g) {
|
2009-09-15 03:52:42 +08:00
|
|
|
/* register the error class */
|
2011-05-05 04:28:09 +08:00
|
|
|
HDsnprintf(lib_str, sizeof(lib_str), "%d.%d.%d",H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE);
|
2012-03-19 22:03:12 +08:00
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
H5tools_ERR_STACK_g = H5Ecreate_stack();
|
2009-09-15 03:52:42 +08:00
|
|
|
H5TOOLS_INIT_ERROR()
|
2010-01-30 12:29:13 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (!rawattrstream)
|
|
|
|
rawattrstream = stdout;
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!rawdatastream)
|
|
|
|
rawdatastream = stdout;
|
2013-07-31 01:04:23 +08:00
|
|
|
if (!rawinstream)
|
|
|
|
rawinstream = stdin;
|
2012-02-25 05:14:47 +08:00
|
|
|
if (!rawoutstream)
|
|
|
|
rawoutstream = stdout;
|
|
|
|
if (!rawerrorstream)
|
|
|
|
rawerrorstream = stderr;
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_dump_init();
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_init_g++;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: Close the H5 Tools library
|
2001-04-11 03:54:08 +08:00
|
|
|
* Description:
|
|
|
|
* Close or release resources such as files opened by the library. This
|
|
|
|
* should be called after all other h5tools functions have been called.
|
|
|
|
* Effect of any h5tools function called after this has been called is
|
|
|
|
* undetermined.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Albert Cheng, 2000-10-31
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
h5tools_close(void)
|
|
|
|
{
|
2012-03-13 00:33:15 +08:00
|
|
|
H5E_auto2_t tools_func;
|
|
|
|
void *tools_edata;
|
2001-02-23 05:55:15 +08:00
|
|
|
if (h5tools_init_g) {
|
2013-02-05 04:15:59 +08:00
|
|
|
/* special case where only data is output to stdout */
|
2013-02-01 04:51:23 +08:00
|
|
|
if((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
|
|
|
|
HDfprintf(rawdatastream, "\n");
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
|
|
|
|
if(tools_func!=NULL)
|
2012-03-13 22:38:37 +08:00
|
|
|
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
|
2013-01-23 04:43:12 +08:00
|
|
|
if (rawattrstream && rawattrstream != stdout) {
|
|
|
|
if (fclose(rawattrstream))
|
|
|
|
perror("closing rawattrstream");
|
|
|
|
else
|
|
|
|
rawattrstream = NULL;
|
|
|
|
}
|
2007-09-13 23:44:56 +08:00
|
|
|
if (rawdatastream && rawdatastream != stdout) {
|
|
|
|
if (fclose(rawdatastream))
|
2009-09-04 22:50:13 +08:00
|
|
|
perror("closing rawdatastream");
|
2007-09-13 23:44:56 +08:00
|
|
|
else
|
2009-09-04 22:50:13 +08:00
|
|
|
rawdatastream = NULL;
|
2007-09-13 23:44:56 +08:00
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
if (rawinstream && rawinstream != stdin) {
|
|
|
|
if (fclose(rawinstream))
|
|
|
|
perror("closing rawinstream");
|
|
|
|
else
|
|
|
|
rawinstream = NULL;
|
|
|
|
}
|
2012-02-25 05:14:47 +08:00
|
|
|
if (rawoutstream && rawoutstream != stdout) {
|
|
|
|
if (fclose(rawoutstream))
|
|
|
|
perror("closing rawoutstream");
|
|
|
|
else
|
|
|
|
rawoutstream = NULL;
|
|
|
|
}
|
|
|
|
if (rawerrorstream && rawerrorstream != stderr) {
|
|
|
|
if (fclose(rawerrorstream))
|
|
|
|
perror("closing rawerrorstream");
|
|
|
|
else
|
|
|
|
rawerrorstream = NULL;
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2005-08-26 04:16:40 +08:00
|
|
|
/* Clean up the reference path table, if it's been used */
|
|
|
|
term_ref_path_table();
|
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
H5TOOLS_CLOSE_ERROR()
|
2012-03-13 00:33:15 +08:00
|
|
|
H5Eclose_stack(H5tools_ERR_STACK_g);
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Shut down the library */
|
|
|
|
H5close();
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
h5tools_init_g = 0;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-31 01:04:23 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_set_data_output_file
|
|
|
|
*
|
|
|
|
* Purpose: Open fname as the output file for dataset raw data.
|
|
|
|
* Set rawdatastream as its file stream.
|
|
|
|
*
|
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
|
|
|
*
|
|
|
|
* Programmer: Albert Cheng, 2000/09/30
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
* pvn June, 1, 2006. Add a switch for binary output
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5tools_set_data_output_file(const char *fname, int is_bin)
|
|
|
|
{
|
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawdatastream is changed only when succeeded */
|
|
|
|
|
|
|
|
if (rawdatastream && rawdatastream != stdout) {
|
|
|
|
if (HDfclose(rawdatastream))
|
|
|
|
HDperror("closing rawdatastream");
|
|
|
|
else
|
|
|
|
rawdatastream = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
|
|
|
if ((f = HDfopen(fname, "wb")) != NULL) {
|
|
|
|
rawdatastream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((f = HDfopen(fname, "w")) != NULL) {
|
|
|
|
rawdatastream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawdatastream = NULL;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_set_attr_output_file
|
|
|
|
*
|
|
|
|
* Purpose: Open fname as the output file for attribute raw data.
|
|
|
|
* Set rawattrstream as its file stream.
|
|
|
|
*
|
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
h5tools_set_attr_output_file(const char *fname, int is_bin)
|
|
|
|
{
|
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawattrstream is changed only when succeeded */
|
|
|
|
|
|
|
|
if (rawattrstream && rawattrstream != stdout) {
|
|
|
|
if (HDfclose(rawattrstream))
|
|
|
|
HDperror("closing rawattrstream");
|
|
|
|
else
|
|
|
|
rawattrstream = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2013-08-01 00:22:40 +08:00
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
|
|
|
if ((f = HDfopen(fname, "wb")) != NULL) {
|
|
|
|
rawattrstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((f = HDfopen(fname, "w")) != NULL) {
|
|
|
|
rawattrstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawattrstream = NULL;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_set_input_file
|
|
|
|
*
|
|
|
|
* Purpose: Open fname as the input file for raw input.
|
|
|
|
* Set rawinstream as its file stream.
|
|
|
|
*
|
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2013-08-01 00:22:40 +08:00
|
|
|
h5tools_set_input_file(const char *fname, int is_bin)
|
2013-07-31 01:04:23 +08:00
|
|
|
{
|
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawinstream is changed only when succeeded */
|
|
|
|
|
|
|
|
if (rawinstream && rawinstream != stdin) {
|
|
|
|
if (HDfclose(rawinstream))
|
|
|
|
HDperror("closing rawinstream");
|
|
|
|
else
|
|
|
|
rawinstream = NULL;
|
|
|
|
}
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2013-08-01 00:22:40 +08:00
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
|
|
|
if ((f = HDfopen(fname, "rb")) != NULL) {
|
|
|
|
rawinstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((f = HDfopen(fname, "r")) != NULL) {
|
|
|
|
rawinstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawinstream = NULL;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_set_output_file
|
|
|
|
*
|
|
|
|
* Purpose: Open fname as the output file for raw output.
|
|
|
|
* Set rawoutstream as its file stream.
|
|
|
|
*
|
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2013-08-01 00:22:40 +08:00
|
|
|
h5tools_set_output_file(const char *fname, int is_bin)
|
2013-07-31 01:04:23 +08:00
|
|
|
{
|
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawoutstream is changed only when succeeded */
|
|
|
|
|
|
|
|
if (rawoutstream && rawoutstream != stdout) {
|
|
|
|
if (HDfclose(rawoutstream))
|
|
|
|
HDperror("closing rawoutstream");
|
|
|
|
else
|
|
|
|
rawoutstream = NULL;
|
|
|
|
}
|
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
2013-08-01 00:22:40 +08:00
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
|
|
|
if ((f = HDfopen(fname, "wb")) != NULL) {
|
|
|
|
rawoutstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((f = HDfopen(fname, "w")) != NULL) {
|
|
|
|
rawoutstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
2013-07-31 01:04:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawoutstream = NULL;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_set_error_file
|
|
|
|
*
|
|
|
|
* Purpose: Open fname as the error output file for dataset raw error.
|
|
|
|
* Set rawerrorstream as its file stream.
|
|
|
|
*
|
|
|
|
* Return: 0 -- succeeded
|
|
|
|
* negative -- failed
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
int
|
2013-08-01 00:22:40 +08:00
|
|
|
h5tools_set_error_file(const char *fname, int is_bin)
|
2013-07-31 01:04:23 +08:00
|
|
|
{
|
|
|
|
int retvalue = FAIL;
|
|
|
|
FILE *f; /* temporary holding place for the stream pointer
|
|
|
|
* so that rawerrorstream is changed only when succeeded */
|
|
|
|
|
|
|
|
if (rawerrorstream && rawerrorstream != stderr) {
|
|
|
|
if (HDfclose(rawerrorstream))
|
|
|
|
HDperror("closing rawerrorstream");
|
|
|
|
else
|
|
|
|
rawerrorstream = NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-01 00:22:40 +08:00
|
|
|
/* First check if filename is string "NULL" */
|
|
|
|
if (fname != NULL) {
|
|
|
|
/* binary output */
|
|
|
|
if (is_bin) {
|
|
|
|
if ((f = HDfopen(fname, "wb")) != NULL) {
|
|
|
|
rawerrorstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if ((f = HDfopen(fname, "w")) != NULL) {
|
|
|
|
rawerrorstream = f;
|
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rawerrorstream = NULL;
|
2013-07-31 01:04:23 +08:00
|
|
|
retvalue = SUCCEED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return retvalue;
|
|
|
|
}
|
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Private
|
|
|
|
* Chapter: H5Tools Library
|
2006-07-27 23:01:48 +08:00
|
|
|
* Purpose: Get a FAPL for a driver
|
2004-02-05 06:43:00 +08:00
|
|
|
* Description:
|
|
|
|
* Get a FAPL for a given VFL driver name.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Quincey Koziol, 2004-02-04
|
|
|
|
* Modifications:
|
2006-07-27 23:01:48 +08:00
|
|
|
* Pedro Vicente Nunes, Thursday, July 27, 2006
|
|
|
|
* Added error return conditions for the H5Pset_fapl calls
|
2004-02-05 06:43:00 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static hid_t
|
2007-02-14 21:54:11 +08:00
|
|
|
h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
|
2004-02-05 06:43:00 +08:00
|
|
|
{
|
2009-09-04 22:50:13 +08:00
|
|
|
hid_t new_fapl; /* Copy of file access property list passed in, or new property list */
|
2007-02-14 21:54:11 +08:00
|
|
|
|
|
|
|
/* Make a copy of the FAPL, for the file open call to use, eventually */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (fapl == H5P_DEFAULT) {
|
|
|
|
if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
|
|
|
} /* end if */
|
|
|
|
else {
|
2009-09-04 22:50:13 +08:00
|
|
|
if ((new_fapl = H5Pcopy(fapl)) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
|
|
|
} /* end else */
|
2004-02-05 06:43:00 +08:00
|
|
|
|
|
|
|
/* Determine which driver the user wants to open the file with. Try
|
|
|
|
* that driver. If it can't open it, then fail. */
|
2012-02-23 05:58:50 +08:00
|
|
|
if (!HDstrcmp(driver, drivernames[SEC2_IDX])) {
|
2007-06-12 02:51:20 +08:00
|
|
|
/* SEC2 driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_sec2(new_fapl) < 0)
|
2007-06-12 02:51:20 +08:00
|
|
|
goto error;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivernum)
|
2004-02-05 06:43:00 +08:00
|
|
|
*drivernum = SEC2_IDX;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else if (!HDstrcmp(driver, drivernames[FAMILY_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* FAMILY Driver */
|
|
|
|
|
2007-02-14 21:54:11 +08:00
|
|
|
/* Set member size to be 0 to indicate the current first member size
|
|
|
|
* is the member size.
|
|
|
|
*/
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivernum)
|
2007-02-14 21:54:11 +08:00
|
|
|
*drivernum = FAMILY_IDX;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* SPLIT Driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivernum)
|
2007-02-14 21:54:11 +08:00
|
|
|
*drivernum = SPLIT_IDX;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2012-02-23 05:58:50 +08:00
|
|
|
else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* MULTI Driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
|
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2007-02-14 21:54:11 +08:00
|
|
|
if(drivernum)
|
2009-09-04 22:50:13 +08:00
|
|
|
*drivernum = MULTI_IDX;
|
2010-01-30 12:29:13 +08:00
|
|
|
}
|
2014-03-22 07:02:24 +08:00
|
|
|
#ifdef H5_HAVE_PARALLEL
|
|
|
|
else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) {
|
2015-06-11 01:57:32 +08:00
|
|
|
int mpi_initialized, mpi_finalized;
|
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
/* MPI-I/O Driver */
|
2015-06-11 01:57:32 +08:00
|
|
|
/* check if MPI is available. */
|
|
|
|
MPI_Initialized(&mpi_initialized);
|
|
|
|
MPI_Finalized(&mpi_finalized);
|
|
|
|
|
|
|
|
if(mpi_initialized && !mpi_finalized) {
|
2014-03-22 07:02:24 +08:00
|
|
|
if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
|
2009-09-04 22:50:13 +08:00
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
if(drivernum)
|
2014-03-22 07:02:24 +08:00
|
|
|
*drivernum = MPIO_IDX;
|
2004-02-05 06:43:00 +08:00
|
|
|
} /* end if */
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2014-03-22 07:02:24 +08:00
|
|
|
#endif /* H5_HAVE_PARALLEL */
|
|
|
|
else
|
2007-02-14 21:54:11 +08:00
|
|
|
goto error;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2007-02-14 21:54:11 +08:00
|
|
|
return(new_fapl);
|
2006-07-27 23:01:48 +08:00
|
|
|
|
|
|
|
error:
|
2007-02-14 21:54:11 +08:00
|
|
|
if(new_fapl != H5P_DEFAULT)
|
|
|
|
H5Pclose(new_fapl);
|
2006-07-27 23:01:48 +08:00
|
|
|
return -1;
|
2004-02-05 06:43:00 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Open a file with various VFL drivers.
|
|
|
|
* Description:
|
|
|
|
* Loop through the various types of VFL drivers trying to open FNAME.
|
|
|
|
* If the HDF5 library is version 1.2 or less, then we have only the SEC2
|
|
|
|
* driver to try out. If the HDF5 library is greater than version 1.2,
|
2014-03-22 07:02:24 +08:00
|
|
|
* then we have the FAMILY, SPLIT, and MULTI drivers to play with.
|
2001-07-31 05:55:46 +08:00
|
|
|
*
|
|
|
|
* If DRIVER is non-NULL, then it will try to open the file with that
|
|
|
|
* driver first. We assume that the user knows what they are doing so, if
|
|
|
|
* we fail, then we won't try other file drivers.
|
2001-04-11 03:54:08 +08:00
|
|
|
* Return:
|
|
|
|
* On success, returns a file id for the opened file. If DRIVERNAME is
|
|
|
|
* non-null then the first DRIVERNAME_SIZE-1 characters of the driver
|
|
|
|
* name are copied into the DRIVERNAME array and null terminated.
|
|
|
|
*
|
|
|
|
* Otherwise, the function returns FAIL. If DRIVERNAME is non-null then
|
|
|
|
* the first byte is set to the null terminator.
|
|
|
|
* Programmer:
|
|
|
|
* Lost in the mists of time.
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* We only have to initialize driver[] on the first call, thereby
|
|
|
|
* preventing memory leaks from repeated calls to H5Pcreate().
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* Added DRIVERNAME_SIZE arg to prevent overflows when writing to
|
|
|
|
* DRIVERNAME.
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* Added test to prevent coredump when the file could not be opened by
|
|
|
|
* any driver.
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 2000-06-23
|
|
|
|
* Changed name from H5ToolsFopen() so it jives better with the names we
|
|
|
|
* already have at the top of this source file.
|
2001-03-09 04:21:05 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Thomas Radke, 2000-09-12
|
|
|
|
* Added Stream VFD to the driver[] array.
|
2001-02-23 05:55:15 +08:00
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Bill Wendling, 2001-01-10
|
|
|
|
* Changed macro behavior so that if we have a version other than 1.2.x
|
|
|
|
* (i.e., > 1.2), then we do the drivers check.
|
2001-07-31 05:55:46 +08:00
|
|
|
*
|
|
|
|
* Bill Wendling, 2001-07-30
|
|
|
|
* Added DRIVER parameter so that the user can specify "try this driver"
|
|
|
|
* instead of the default behaviour. If it fails to open the file with
|
|
|
|
* that driver, this will fail completely (i.e., we won't try the other
|
|
|
|
* drivers). We're assuming the user knows what they're doing. How UNIX
|
|
|
|
* of us.
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
hid_t
|
2007-02-14 21:54:11 +08:00
|
|
|
h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver,
|
2007-02-14 06:42:43 +08:00
|
|
|
char *drivername, size_t drivername_size)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2004-02-05 06:43:00 +08:00
|
|
|
unsigned drivernum;
|
|
|
|
hid_t fid = FAIL;
|
2007-02-14 21:54:11 +08:00
|
|
|
hid_t my_fapl = H5P_DEFAULT;
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (driver && *driver) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Get the correct FAPL for the given driver */
|
2009-09-04 22:50:13 +08:00
|
|
|
if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0)
|
2004-02-05 06:43:00 +08:00
|
|
|
goto done;
|
2001-07-31 05:55:46 +08:00
|
|
|
|
2004-02-05 06:43:00 +08:00
|
|
|
H5E_BEGIN_TRY {
|
2007-02-14 21:54:11 +08:00
|
|
|
fid = H5Fopen(fname, flags, my_fapl);
|
2004-02-05 06:43:00 +08:00
|
|
|
} H5E_END_TRY;
|
2001-07-31 05:55:46 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (fid == FAIL)
|
2001-07-31 05:55:46 +08:00
|
|
|
goto done;
|
2004-02-05 06:43:00 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2001-07-31 05:55:46 +08:00
|
|
|
/* Try to open the file using each of the drivers */
|
2009-09-04 22:50:13 +08:00
|
|
|
for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
|
2004-02-05 06:43:00 +08:00
|
|
|
/* Get the correct FAPL for the given driver */
|
2007-02-14 21:54:11 +08:00
|
|
|
if((my_fapl = h5tools_get_fapl(fapl, drivernames[drivernum], NULL)) < 0)
|
2004-02-05 06:43:00 +08:00
|
|
|
goto done;
|
|
|
|
|
2001-07-31 05:55:46 +08:00
|
|
|
H5E_BEGIN_TRY {
|
2007-02-14 21:54:11 +08:00
|
|
|
fid = H5Fopen(fname, flags, my_fapl);
|
2001-07-31 05:55:46 +08:00
|
|
|
} H5E_END_TRY;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (fid != FAIL)
|
2001-07-31 05:55:46 +08:00
|
|
|
break;
|
2004-02-05 06:43:00 +08:00
|
|
|
else {
|
|
|
|
/* Close the FAPL */
|
2007-02-14 21:54:11 +08:00
|
|
|
H5Pclose(my_fapl);
|
|
|
|
my_fapl = H5P_DEFAULT;
|
2004-02-05 06:43:00 +08:00
|
|
|
} /* end else */
|
2001-07-31 05:55:46 +08:00
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Save the driver name */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (drivername && drivername_size) {
|
|
|
|
if (fid != FAIL) {
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrncpy(drivername, drivernames[drivernum], drivername_size);
|
2001-03-09 04:21:05 +08:00
|
|
|
drivername[drivername_size - 1] = '\0';
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
2001-04-11 03:54:08 +08:00
|
|
|
/*no file opened*/
|
|
|
|
drivername[0] = '\0';
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2001-07-31 05:55:46 +08:00
|
|
|
done:
|
2007-02-14 21:54:11 +08:00
|
|
|
if(my_fapl != H5P_DEFAULT)
|
|
|
|
H5Pclose(my_fapl);
|
2009-09-15 05:48:32 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
return fid;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Count the number of columns in a string.
|
|
|
|
* Description:
|
|
|
|
* Count the number of columns in a string. This is the number of
|
|
|
|
* characters in the string not counting line-control characters.
|
|
|
|
* Return:
|
|
|
|
* On success, returns the width of the string. Otherwise this function
|
|
|
|
* returns 0.
|
|
|
|
* Programmer:
|
|
|
|
* Robb Matzke, Tuesday, April 27, 1999
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2001-03-09 04:21:05 +08:00
|
|
|
static size_t
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_count_ncols(const char *s)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2001-03-09 04:21:05 +08:00
|
|
|
register size_t i;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
for (i = 0; *s; s++)
|
|
|
|
if (*s >= ' ')
|
|
|
|
i++;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
return i;
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
2011-03-19 02:50:19 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2011-03-22 07:02:31 +08:00
|
|
|
* Function: h5tools_detect_vlen
|
2011-03-19 02:50:19 +08:00
|
|
|
*
|
|
|
|
* Purpose: Recursive check for any variable length data in given type.
|
|
|
|
*
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
* Return:
|
2011-03-22 07:02:31 +08:00
|
|
|
* TRUE : type conatains any variable length data
|
|
|
|
* FALSE : type doesn't contain any variable length data
|
|
|
|
* Negative value: error occur
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
*
|
2011-03-19 02:50:19 +08:00
|
|
|
* Programmer: Jonathan Kim March 18, 2011
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
2011-03-22 07:02:31 +08:00
|
|
|
h5tools_detect_vlen(hid_t tid)
|
2011-03-19 02:50:19 +08:00
|
|
|
{
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
htri_t ret;
|
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
/* recursive detect any vlen data values in type (compound, array ...) */
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = H5Tdetect_class(tid, H5T_VLEN);
|
|
|
|
if((ret == TRUE) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-19 02:50:19 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
/* recursive detect any vlen string in type (compound, array ...) */
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
ret = h5tools_detect_vlen_str(tid);
|
|
|
|
if((ret == TRUE) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
2011-03-19 02:50:19 +08:00
|
|
|
}
|
|
|
|
|
2011-03-10 04:00:20 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2011-03-15 05:03:20 +08:00
|
|
|
* Function: h5tools_detect_vlen_str
|
2011-03-10 04:00:20 +08:00
|
|
|
*
|
|
|
|
* Purpose: Recursive check for variable length string of a datatype.
|
|
|
|
*
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
* Return:
|
2011-03-22 07:02:31 +08:00
|
|
|
* TRUE : type conatains any variable length string
|
|
|
|
* FALSE : type doesn't contain any variable length string
|
|
|
|
* Negative value: error occur
|
2011-03-10 04:00:20 +08:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
htri_t
|
2011-03-15 05:03:20 +08:00
|
|
|
h5tools_detect_vlen_str(hid_t tid)
|
2011-03-10 04:00:20 +08:00
|
|
|
{
|
|
|
|
H5T_class_t tclass = -1;
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
htri_t ret = FALSE;
|
2011-03-10 04:00:20 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
ret = H5Tis_variable_str(tid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if((ret == TRUE) || (ret < 0))
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-10 04:00:20 +08:00
|
|
|
|
|
|
|
tclass = H5Tget_class(tid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if(tclass == H5T_ARRAY || tclass == H5T_VLEN) {
|
|
|
|
hid_t btid = H5Tget_super(tid);
|
|
|
|
|
|
|
|
if(btid < 0) {
|
|
|
|
ret = (htri_t)btid;
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
ret = h5tools_detect_vlen_str(btid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if((ret == TRUE) || (ret < 0)) {
|
2011-03-22 07:02:31 +08:00
|
|
|
H5Tclose(btid);
|
|
|
|
goto done;
|
|
|
|
}
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
else if(tclass == H5T_COMPOUND) {
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
unsigned nmembs;
|
|
|
|
int snmembs = H5Tget_nmembers(tid);
|
|
|
|
unsigned u;
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
if(snmembs < 0) {
|
|
|
|
ret = FAIL;
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
|
|
|
}
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
nmembs = (unsigned)snmembs;
|
2011-03-22 07:02:31 +08:00
|
|
|
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
for(u = 0; u < nmembs; u++) {
|
|
|
|
hid_t mtid = H5Tget_member_type(tid, u);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
|
2011-03-22 07:02:31 +08:00
|
|
|
ret = h5tools_detect_vlen_str(mtid);
|
[svn-r20539] Description:
Bring Coverity changes back to trunk:
r20276:
Add recursive is vlen string function.
Cleanup resource leaks for issues: 200,202,329,688,811,812
r20277:
Check types and close by adding error section: issue 687
r20278:
Replaced implicit pointer conversion with (ocrt_info.new_obj != NULL).
r20280:
Addressed coverity issues 927-929 & 583. The real issue is failure to check
file name length -- at least at the H5FD interface level. This needs more work, but at least I have dealt with the issue in H5FDfamily.c
r20337:
H5O_type_t obj_type = H5O_TYPE_UNKNOWN;
r20338:
Added udata.name = NULL; to prevent potential uninitialized use after done: label.
r20339:
coverity issues: 686,828,1670-1673,1707-1711
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
FreeBSD/32 8.2 (loyalty) w/gcc4.6, in debug mode
FreeBSD/64 8.2 (freedom) w/gcc4.6, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
2011-04-18 18:18:47 +08:00
|
|
|
if((ret == TRUE) || (ret < 0)) {
|
2011-03-10 04:00:20 +08:00
|
|
|
H5Tclose(mtid);
|
2011-03-22 07:02:31 +08:00
|
|
|
goto done;
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
|
|
|
H5Tclose(mtid);
|
|
|
|
}
|
|
|
|
}
|
2011-03-22 07:02:31 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
return ret;
|
2011-03-10 04:00:20 +08:00
|
|
|
}
|
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Emit a simple prefix to STREAM.
|
|
|
|
* Description:
|
|
|
|
* If /ctx->need_prefix/ is set then terminate the current line (if
|
|
|
|
* applicable), calculate the prefix string, and display it at the start
|
|
|
|
* of a line.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
* Programmer:
|
|
|
|
* Robb Matzke, Monday, April 26, 1999
|
2001-02-23 05:55:15 +08:00
|
|
|
* Modifications:
|
2001-04-11 03:54:08 +08:00
|
|
|
* Robb Matzke, 1999-09-29
|
2006-07-27 23:01:48 +08:00
|
|
|
* If a new prefix is printed then the current element number is set back
|
|
|
|
* to zero.
|
2004-07-09 05:49:40 +08:00
|
|
|
* pvn, 2004-07-08
|
2005-08-14 04:53:35 +08:00
|
|
|
* Added support for printing array indices:
|
2004-07-01 02:45:14 +08:00
|
|
|
* the indentation is printed before the prefix (printed one indentation
|
2005-08-14 04:53:35 +08:00
|
|
|
* level before)
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
2006-01-24 04:46:34 +08:00
|
|
|
h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info,
|
2001-03-09 04:21:05 +08:00
|
|
|
h5tools_context_t *ctx, hsize_t elmtno, int secnum)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2001-03-09 04:21:05 +08:00
|
|
|
h5tools_str_t prefix;
|
2004-07-01 02:45:14 +08:00
|
|
|
h5tools_str_t str; /*temporary for indentation */
|
2001-03-09 04:21:05 +08:00
|
|
|
size_t templength = 0;
|
|
|
|
int i, indentlevel = 0;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (stream == NULL)
|
|
|
|
return;
|
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
if (!ctx->need_prefix)
|
2009-09-04 22:50:13 +08:00
|
|
|
return;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
HDmemset(&prefix, 0, sizeof(h5tools_str_t));
|
|
|
|
HDmemset(&str, 0, sizeof(h5tools_str_t));
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Terminate previous line, if any */
|
|
|
|
if (ctx->cur_column) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_suf, ""), stream);
|
2012-02-23 05:58:50 +08:00
|
|
|
HDputc('\n', stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_sep, ""), stream);
|
2001-03-09 04:21:05 +08:00
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Calculate new prefix */
|
2010-08-13 05:11:00 +08:00
|
|
|
h5tools_str_prefix(&prefix, info, elmtno, ctx->ndims, ctx);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
/* Write new prefix to output */
|
|
|
|
if (ctx->indent_level >= 0) {
|
|
|
|
indentlevel = ctx->indent_level;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* This is because sometimes we don't print out all the header
|
|
|
|
* info for the data (like the tattr-2.ddl example). If that happens
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* when printing array indices, print the indentation before the prefix
|
|
|
|
the prefix is printed one indentation level before */
|
|
|
|
if (info->pindex) {
|
|
|
|
for (i = 0; i < indentlevel - 1; i++) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (elmtno == 0 && secnum == 0 && info->line_1st) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
}
|
|
|
|
else if (secnum && info->line_cont) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
}
|
|
|
|
else {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
templength = h5tools_str_len(&prefix);
|
|
|
|
|
|
|
|
for (i = 0; i < indentlevel; i++) {
|
|
|
|
/*we already made the indent for the array indices case */
|
|
|
|
if (!info->pindex) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
templength += h5tools_str_len(&prefix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*we cannot count the prefix for the array indices case */
|
|
|
|
templength += h5tools_str_len(&str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->cur_column = ctx->prev_prefix_len = templength;
|
|
|
|
ctx->cur_elmt = 0;
|
|
|
|
ctx->need_prefix = 0;
|
|
|
|
|
|
|
|
/* Free string */
|
|
|
|
h5tools_str_close(&prefix);
|
|
|
|
h5tools_str_close(&str);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Emit a simple prefix to STREAM.
|
|
|
|
* Description:
|
|
|
|
* If /ctx->need_prefix/ is set then terminate the current line (if
|
|
|
|
* applicable), calculate the prefix string, and display it at the start
|
|
|
|
* of a line. Calls region specific function.
|
|
|
|
* Return:
|
|
|
|
* None
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_region_simple_prefix(FILE *stream, const h5tool_format_t *info,
|
2010-01-30 12:29:13 +08:00
|
|
|
h5tools_context_t *ctx, hsize_t elmtno, hsize_t *ptdata, int secnum)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
h5tools_str_t prefix;
|
|
|
|
h5tools_str_t str; /*temporary for indentation */
|
|
|
|
size_t templength = 0;
|
|
|
|
int i, indentlevel = 0;
|
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (stream == NULL)
|
|
|
|
return;
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!ctx->need_prefix)
|
|
|
|
return;
|
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
HDmemset(&prefix, 0, sizeof(h5tools_str_t));
|
|
|
|
HDmemset(&str, 0, sizeof(h5tools_str_t));
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Terminate previous line, if any */
|
|
|
|
if (ctx->cur_column) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_suf, ""), stream);
|
2012-02-23 05:58:50 +08:00
|
|
|
HDputc('\n', stream);
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->line_sep, ""), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate new prefix */
|
2011-05-12 04:45:54 +08:00
|
|
|
h5tools_str_region_prefix(&prefix, info, elmtno, ptdata, ctx->ndims, ctx->p_max_idx, ctx);
|
2009-09-04 22:50:13 +08:00
|
|
|
|
|
|
|
/* Write new prefix to output */
|
2014-03-22 07:02:24 +08:00
|
|
|
if (ctx->indent_level >= 0)
|
2009-09-04 22:50:13 +08:00
|
|
|
indentlevel = ctx->indent_level;
|
2014-03-22 07:02:24 +08:00
|
|
|
else
|
2001-03-09 04:21:05 +08:00
|
|
|
/*
|
2001-04-11 03:54:08 +08:00
|
|
|
* This is because sometimes we don't print out all the header
|
|
|
|
* info for the data (like the tattr-2.ddl example). If that happens
|
|
|
|
* the ctx->indent_level is negative so we need to skip the above and
|
|
|
|
* just print out the default indent levels.
|
2001-03-09 04:21:05 +08:00
|
|
|
*/
|
2009-09-04 22:50:13 +08:00
|
|
|
indentlevel = ctx->default_indent_level;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2004-07-01 02:45:14 +08:00
|
|
|
/* when printing array indices, print the indentation before the prefix
|
|
|
|
the prefix is printed one indentation level before */
|
2014-03-22 07:02:24 +08:00
|
|
|
if (info->pindex)
|
2009-09-04 22:50:13 +08:00
|
|
|
for (i = 0; i < indentlevel - 1; i++) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&str, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2004-07-01 02:45:14 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (elmtno == 0 && secnum == 0 && info->line_1st) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_1st), stream);
|
2014-03-22 07:02:24 +08:00
|
|
|
} else if (secnum && info->line_cont) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_cont), stream);
|
2014-03-22 07:02:24 +08:00
|
|
|
} else
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_pre), stream);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2001-03-09 04:21:05 +08:00
|
|
|
templength = h5tools_str_len(&prefix);
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
for (i = 0; i < indentlevel; i++) {
|
2004-07-01 02:45:14 +08:00
|
|
|
/*we already made the indent for the array indices case */
|
2009-09-04 22:50:13 +08:00
|
|
|
if (!info->pindex) {
|
2013-10-11 05:57:04 +08:00
|
|
|
PUTSTREAM(h5tools_str_fmt(&prefix, (size_t)0, info->line_indent), stream);
|
2009-09-04 22:50:13 +08:00
|
|
|
templength += h5tools_str_len(&prefix);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*we cannot count the prefix for the array indices case */
|
|
|
|
templength += h5tools_str_len(&str);
|
|
|
|
}
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ctx->cur_column = ctx->prev_prefix_len = templength;
|
|
|
|
ctx->cur_elmt = 0;
|
|
|
|
ctx->need_prefix = 0;
|
|
|
|
|
|
|
|
/* Free string */
|
|
|
|
h5tools_str_close(&prefix);
|
2004-07-01 02:45:14 +08:00
|
|
|
h5tools_str_close(&str);
|
2001-02-23 05:55:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2001-04-11 03:54:08 +08:00
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
2009-09-04 22:50:13 +08:00
|
|
|
* Purpose: Render an element to output STREAM.
|
2001-04-11 03:54:08 +08:00
|
|
|
* Description:
|
2009-09-04 22:50:13 +08:00
|
|
|
* Prints the string buffer to the output STREAM. The string is
|
2010-01-30 12:29:13 +08:00
|
|
|
* printed according to the format described in INFO. The CTX struct
|
|
|
|
* contains context information shared between calls to this function.
|
|
|
|
*
|
2001-04-11 03:54:08 +08:00
|
|
|
* Return:
|
2009-09-04 22:50:13 +08:00
|
|
|
* False if a dimension end is reached, otherwise true
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2009-09-04 22:50:13 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* h5tools_str_t *buffer
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t local_elmt_counter is the local element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
2001-02-23 05:55:15 +08:00
|
|
|
*-------------------------------------------------------------------------
|
2005-08-14 04:53:35 +08:00
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
hbool_t
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_render_element(FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
|
2010-01-30 12:29:13 +08:00
|
|
|
size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter)
|
2001-02-23 05:55:15 +08:00
|
|
|
{
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
char *s;
|
|
|
|
char *section; /*a section of output */
|
|
|
|
int secnum; /*section sequence number */
|
|
|
|
int multiline; /*datum was multiline */
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
if (stream == NULL)
|
|
|
|
return dimension_break;
|
|
|
|
|
2013-10-11 05:57:04 +08:00
|
|
|
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the element would split on multiple lines if printed at our
|
|
|
|
* current location...
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
2012-02-18 05:41:58 +08:00
|
|
|
(ctx->cur_column + h5tools_count_ncols(s) +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) > ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
if (ctx->prev_multiline) {
|
|
|
|
/*
|
|
|
|
* ... and the previous element also occupied more than one
|
|
|
|
* line, then start this element at the beginning of a line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* ...but *could* fit on one line otherwise, then we
|
|
|
|
* should end the current line and start this element on its
|
|
|
|
* own line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2001-04-11 03:54:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* We need to break after each row of a dimension---> we should
|
|
|
|
* break at the end of the each last dimension well that is the
|
|
|
|
* way the dumper did it before
|
|
|
|
*/
|
|
|
|
if (info->arr_linebreak && ctx->cur_elmt) {
|
|
|
|
if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0)
|
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (elmt_counter == ctx->size_last_dim) {
|
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = FALSE;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2001-02-23 05:55:15 +08:00
|
|
|
/*
|
2009-09-04 22:50:13 +08:00
|
|
|
* If the previous element occupied multiple lines and this element
|
|
|
|
* is too long to fit on a line then start this element at the
|
|
|
|
* beginning of the line.
|
2001-02-23 05:55:15 +08:00
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
|
|
|
ctx->prev_multiline &&
|
|
|
|
(ctx->cur_column +
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_count_ncols(s) +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If too many elements have already been printed then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
|
|
|
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
|
|
|
|
ctx->need_prefix = TRUE;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
|
|
|
|
* the data to split across multiple lines. We display the sections
|
|
|
|
* one-at a time.
|
|
|
|
*/
|
|
|
|
multiline = 0;
|
2010-01-30 12:29:13 +08:00
|
|
|
for (secnum = 0, multiline = 0;
|
2012-02-23 05:58:50 +08:00
|
|
|
(section = HDstrtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK));
|
2009-09-04 22:50:13 +08:00
|
|
|
secnum++) {
|
|
|
|
/*
|
|
|
|
* If the current section plus possible suffix and end-of-line
|
|
|
|
* information would cause the output to wrap then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
2011-02-16 03:28:48 +08:00
|
|
|
* check for displaying prefix for each section
|
2009-09-04 22:50:13 +08:00
|
|
|
*/
|
2012-02-23 05:58:50 +08:00
|
|
|
if ( (ctx->cur_column + HDstrlen(section) +
|
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = 1;
|
2001-02-23 05:55:15 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Print the prefix or separate the beginning of this element
|
|
|
|
* from the previous element.
|
|
|
|
*/
|
|
|
|
if (ctx->need_prefix) {
|
|
|
|
if (secnum)
|
|
|
|
multiline++;
|
2007-01-11 03:15:16 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
*curr_pos = ctx->sm_pos + local_elmt_counter;
|
2008-01-15 02:47:50 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_simple_prefix(stream, info, ctx, *curr_pos, secnum);
|
|
|
|
}
|
|
|
|
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
|
2012-02-23 05:58:50 +08:00
|
|
|
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
|
2008-01-15 02:47:50 +08:00
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print the section */
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(section, stream);
|
2012-02-23 05:58:50 +08:00
|
|
|
ctx->cur_column += HDstrlen(section);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2008-01-11 05:31:28 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->prev_multiline = multiline;
|
|
|
|
return dimension_break;
|
|
|
|
}
|
2001-03-09 04:21:05 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Render a region element to output STREAM.
|
|
|
|
* Description:
|
|
|
|
* Prints the string buffer to the output STREAM. The string is
|
2010-01-30 12:29:13 +08:00
|
|
|
* printed according to the format described in INFO. The CTX struct
|
|
|
|
* contains context information shared between calls to this function.
|
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Return:
|
|
|
|
* False if a dimension end is reached, otherwise true
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
|
|
|
* In/Out:
|
2009-09-04 22:50:13 +08:00
|
|
|
* h5tools_context_t *ctx
|
|
|
|
* h5tools_str_t *buffer
|
|
|
|
* hsize_t *curr_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2009-09-04 22:50:13 +08:00
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* hsize_t curr_pos is the total data element position
|
|
|
|
* size_t ncols
|
|
|
|
* hsize_t *ptdata
|
|
|
|
* hsize_t local_elmt_counter is the local element loop counter
|
|
|
|
* hsize_t elmt_count is the data element loop counter
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
hbool_t
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_render_region_element(FILE *stream, const h5tool_format_t *info,
|
|
|
|
h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos,
|
2010-01-30 12:29:13 +08:00
|
|
|
size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
2009-09-08 22:51:59 +08:00
|
|
|
hbool_t dimension_break = TRUE;
|
|
|
|
char *s;
|
|
|
|
char *section; /*a section of output */
|
|
|
|
int secnum; /*section sequence number */
|
|
|
|
int multiline; /*datum was multiline */
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2013-10-11 05:57:04 +08:00
|
|
|
s = h5tools_str_fmt(buffer, (size_t)0, "%s");
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the element would split on multiple lines if printed at our
|
|
|
|
* current location...
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
2012-02-18 05:41:58 +08:00
|
|
|
(ctx->cur_column + h5tools_count_ncols(s) +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) > ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
if (ctx->prev_multiline) {
|
|
|
|
/*
|
|
|
|
* ... and the previous element also occupied more than one
|
|
|
|
* line, then start this element at the beginning of a line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
else if ((ctx->prev_prefix_len + h5tools_count_ncols(s) +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) <= ncols) {
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* ...but *could* fit on one line otherwise, then we
|
|
|
|
* should end the current line and start this element on its
|
|
|
|
* own line.
|
|
|
|
*/
|
|
|
|
ctx->need_prefix = TRUE;
|
2007-01-11 03:15:16 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* We need to break after each row of a dimension---> we should
|
|
|
|
* break at the end of the each last dimension well that is the
|
|
|
|
* way the dumper did it before
|
|
|
|
*/
|
|
|
|
if (info->arr_linebreak && ctx->cur_elmt) {
|
|
|
|
if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0)
|
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
if (elmt_counter == ctx->size_last_dim) {
|
|
|
|
ctx->need_prefix = TRUE;
|
2009-09-08 22:51:59 +08:00
|
|
|
dimension_break = FALSE;
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
|
|
|
}
|
2001-03-16 03:31:40 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If the previous element occupied multiple lines and this element
|
|
|
|
* is too long to fit on a line then start this element at the
|
|
|
|
* beginning of the line.
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if (info->line_multi_new == 1 &&
|
|
|
|
ctx->prev_multiline &&
|
|
|
|
(ctx->cur_column +
|
2012-02-18 05:41:58 +08:00
|
|
|
h5tools_count_ncols(s) +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = TRUE;
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* If too many elements have already been printed then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
|
|
|
if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line)
|
|
|
|
ctx->need_prefix = TRUE;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause
|
|
|
|
* the data to split across multiple lines. We display the sections
|
|
|
|
* one-at a time.
|
|
|
|
*/
|
|
|
|
multiline = 0;
|
2012-02-23 05:58:50 +08:00
|
|
|
for (secnum = 0, multiline = 0; (section = HDstrtok(secnum ? NULL : s,
|
2009-09-04 22:50:13 +08:00
|
|
|
OPTIONAL_LINE_BREAK)); secnum++) {
|
|
|
|
/*
|
|
|
|
* If the current section plus possible suffix and end-of-line
|
|
|
|
* information would cause the output to wrap then we need to
|
|
|
|
* start a new line.
|
|
|
|
*/
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Added the info->skip_first because the dumper does not want
|
|
|
|
* this check to happen for the first line
|
|
|
|
*/
|
2010-01-30 12:29:13 +08:00
|
|
|
if ((!info->skip_first || local_elmt_counter) &&
|
|
|
|
(ctx->cur_column +
|
2012-02-23 05:58:50 +08:00
|
|
|
HDstrlen(section) +
|
|
|
|
HDstrlen(OPT(info->elmt_suf2, " ")) +
|
|
|
|
HDstrlen(OPT(info->line_suf, ""))) > ncols)
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->need_prefix = 1;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*
|
|
|
|
* Print the prefix or separate the beginning of this element
|
|
|
|
* from the previous element.
|
|
|
|
*/
|
|
|
|
if (ctx->need_prefix) {
|
|
|
|
if (secnum)
|
|
|
|
multiline++;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* 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
|
|
|
|
*/
|
|
|
|
*curr_pos = ctx->sm_pos + local_elmt_counter;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
h5tools_region_simple_prefix(stream, info, ctx, local_elmt_counter, ptdata, secnum);
|
2001-04-11 03:54:08 +08:00
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
else if ((local_elmt_counter || ctx->continuation) && secnum == 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(OPT(info->elmt_suf2, " "), stream);
|
2012-02-23 05:58:50 +08:00
|
|
|
ctx->cur_column += HDstrlen(OPT(info->elmt_suf2, " "));
|
2001-04-11 03:54:08 +08:00
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/* Print the section */
|
2013-01-23 04:43:12 +08:00
|
|
|
PUTSTREAM(section, stream);
|
2012-02-23 05:58:50 +08:00
|
|
|
ctx->cur_column += HDstrlen(section);
|
2009-09-04 22:50:13 +08:00
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
ctx->prev_multiline = multiline;
|
|
|
|
return dimension_break;
|
|
|
|
}
|
[svn-r14437] bug fix for h5dump subsetting (deal with blocks)and new test runs
add a check for block overlap after the command line parsing
* Algorithm
*
* In a inner loop, the parameters from SSET are translated into temporary
* variables so that 1 row is printed at a time (getting the coordinate indices
* at each row).
* We define the stride, count and block to be 1 in the row dimension to achieve
* this and advance until all points are printed.
* An outer loop for cases where dimensionality is greater than 2D is made.
* In each iteration, the 2D block is displayed in the inner loop. The remaining
* slower dimensions above the first 2 are incremented one at a time in the outer loop
*
* The element position is obtained from the matrix according to:
* Given an index I(z,y,x) its position from the beginning of an array
* of sizes A(size_z, size_y,size_x) is given by
* Position of I(z,y,x) = index_z * size_y * size_x
* + index_y * size_x
* + index_x
*
tested: windows, linux
2008-01-17 00:12:08 +08:00
|
|
|
|
2009-09-15 03:52:42 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
* Function: init_acc_pos
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
* Purpose: initialize accumulator and matrix position
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
* Return: void
|
2009-09-15 03:52:42 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
void
|
|
|
|
init_acc_pos(h5tools_context_t *ctx, hsize_t *dims)
|
2010-10-21 21:08:44 +08:00
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
int i;
|
2012-05-26 01:39:07 +08:00
|
|
|
unsigned j;
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2012-02-24 03:08:09 +08:00
|
|
|
HDassert(ctx->ndims);
|
2009-09-15 03:52:42 +08:00
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
ctx->acc[ctx->ndims - 1] = 1;
|
|
|
|
for (i = (ctx->ndims - 2); i >= 0; i--) {
|
|
|
|
ctx->acc[i] = ctx->acc[i + 1] * dims[i + 1];
|
2009-09-15 03:52:42 +08:00
|
|
|
}
|
2012-05-26 01:39:07 +08:00
|
|
|
for (j = 0; j < ctx->ndims; j++)
|
|
|
|
ctx->pos[j] = 0;
|
2009-09-15 03:52:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
* Function: render_bin_output
|
2010-01-30 12:29:13 +08:00
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
* Purpose: Write one element of memory buffer to a binary file stream
|
2006-06-26 22:41:59 +08:00
|
|
|
*
|
2006-07-27 23:01:48 +08:00
|
|
|
* Return: Success: SUCCEED
|
|
|
|
* Failure: FAIL
|
2006-06-26 22:41:59 +08:00
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-07-26 06:17:48 +08:00
|
|
|
int
|
|
|
|
render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts)
|
|
|
|
{
|
|
|
|
HERR_INIT(int, SUCCEED)
|
|
|
|
unsigned char *mem = (unsigned char*)_mem;
|
|
|
|
size_t size; /* datum size */
|
|
|
|
hsize_t block_index;
|
|
|
|
H5T_class_t type_class;
|
|
|
|
|
|
|
|
if((size = H5Tget_size(tid)) == 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
|
|
|
if((type_class = H5Tget_class(tid)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed");
|
|
|
|
|
|
|
|
switch (type_class) {
|
|
|
|
case H5T_INTEGER:
|
|
|
|
case H5T_FLOAT:
|
|
|
|
case H5T_ENUM:
|
|
|
|
block_index = block_nelmts * size;
|
|
|
|
while(block_index > 0) {
|
|
|
|
size_t bytes_in = 0; /* # of bytes to write */
|
|
|
|
size_t bytes_wrote = 0; /* # of bytes written */
|
|
|
|
|
|
|
|
if(block_index > sizeof(size_t))
|
|
|
|
bytes_in = sizeof(size_t);
|
|
|
|
else
|
|
|
|
bytes_in = (size_t)block_index;
|
|
|
|
|
|
|
|
bytes_wrote = HDfwrite(mem, 1, bytes_in, stream);
|
|
|
|
|
|
|
|
if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream)))
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
|
|
|
|
|
|
|
block_index -= (hsize_t)bytes_wrote;
|
|
|
|
mem = mem + bytes_wrote;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5T_STRING:
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
H5T_str_t pad;
|
|
|
|
char *s;
|
|
|
|
unsigned char tempuchar;
|
|
|
|
|
|
|
|
pad = H5Tget_strpad(tid);
|
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2012-07-26 21:32:12 +08:00
|
|
|
mem = ((unsigned char*)_mem) + block_index * size;
|
2012-07-26 06:17:48 +08:00
|
|
|
|
|
|
|
if (H5Tis_variable_str(tid)) {
|
|
|
|
s = *(char**) mem;
|
|
|
|
if (s != NULL)
|
|
|
|
size = HDstrlen(s);
|
[svn-r23695] Description:
Clean up warnings in H5Tconv.c (down to _only_ 9000 lines of output now!)
Merge changes from Coverity branch back to trunk:
r20684:
Fix for coverity bug #1721 which was due to the fix for coverity bug #943.
r20685:
Use HDstrncpy. --gh
r20761:
Purpose: Fix valgrind issues
Description:
Free image_data and data as appropriate in test_image.
r20762:
Purpose: Fix coverity issue 600
Description:
Add check for return value of H5O_close in H5Ocopy. Also cleaned up various
warnings.
r20763:
Purpose: Fix valgrind issues with h5stat
Description:
Modified h5stat to free "iter" before exit, and free "hand" before exit if
parse_command_line exits directly.
r20764:
fixed coverity issues:
69, 327, 614, 684, 685, 696, 697, 1681, 967, 826, 660, 80
r20765:
Fixed coverity bug 668
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program but I did add a check that n_elements is >= 1.
I also changed an error condition from doing its own close and returning -1 to "goto out;" like the rest of the program.
r20766:
Fixed coverity bug 667
Pulled x * y * z multiply out of malloc operand into a separate n_elements variable to quiet integer overflow warning.
No actual integer overflow tests are performed since it's just a test program.
Tested on:
Mac OSX/64 10.8.3 (amazon) w/C++ & FORTRAN
(h5committest upcoming)
2013-05-11 23:59:48 +08:00
|
|
|
else
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "NULL string");
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
s = (char *) mem;
|
|
|
|
}
|
|
|
|
for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) {
|
|
|
|
HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char));
|
2013-01-15 00:26:22 +08:00
|
|
|
if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream))
|
2012-07-26 06:17:48 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
|
|
|
} /* i */
|
|
|
|
} /* for (block_index = 0; block_index < block_nelmts; block_index++) */
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5T_COMPOUND:
|
|
|
|
{
|
2013-02-02 09:53:32 +08:00
|
|
|
int snmembs;
|
2012-07-26 06:17:48 +08:00
|
|
|
unsigned nmembs;
|
|
|
|
|
2013-02-02 09:53:32 +08:00
|
|
|
if((snmembs = H5Tget_nmembers(tid)) < 0)
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed");
|
|
|
|
nmembs = (unsigned)snmembs;
|
2012-07-26 06:17:48 +08:00
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2013-02-02 09:53:32 +08:00
|
|
|
unsigned j;
|
|
|
|
|
2012-07-26 21:32:12 +08:00
|
|
|
mem = ((unsigned char*)_mem) + block_index * size;
|
2012-07-26 06:17:48 +08:00
|
|
|
for (j = 0; j < nmembs; j++) {
|
2013-02-02 09:53:32 +08:00
|
|
|
hid_t memb;
|
|
|
|
size_t offset;
|
|
|
|
|
2012-07-26 06:17:48 +08:00
|
|
|
offset = H5Tget_member_offset(tid, j);
|
|
|
|
memb = H5Tget_member_type(tid, j);
|
|
|
|
|
2013-09-06 04:44:14 +08:00
|
|
|
if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) {
|
|
|
|
H5Tclose(memb);
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output of compound member failed");
|
|
|
|
}
|
2012-07-26 06:17:48 +08:00
|
|
|
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5T_ARRAY:
|
|
|
|
{
|
|
|
|
int k, ndims;
|
2013-02-02 09:53:32 +08:00
|
|
|
hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts;
|
2012-07-26 06:17:48 +08:00
|
|
|
hid_t memb;
|
|
|
|
|
|
|
|
/* get the array's base datatype for each element */
|
|
|
|
memb = H5Tget_super(tid);
|
|
|
|
ndims = H5Tget_array_ndims(tid);
|
|
|
|
H5Tget_array_dims2(tid, dims);
|
|
|
|
HDassert(ndims >= 1 && ndims <= H5S_MAX_RANK);
|
|
|
|
|
|
|
|
/* calculate the number of array elements */
|
|
|
|
for (k = 0, nelmts = 1; k < ndims; k++) {
|
|
|
|
temp_nelmts = nelmts;
|
|
|
|
temp_nelmts *= dims[k];
|
|
|
|
nelmts = (size_t) temp_nelmts;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2012-07-26 21:32:12 +08:00
|
|
|
mem = ((unsigned char*)_mem) + block_index * size;
|
2012-07-26 06:17:48 +08:00
|
|
|
/* dump the array element */
|
2013-09-06 04:44:14 +08:00
|
|
|
if (render_bin_output(stream, container, memb, mem, nelmts) < 0) {
|
|
|
|
H5Tclose(memb);
|
2012-07-26 06:17:48 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
|
2013-09-06 04:44:14 +08:00
|
|
|
}
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5T_VLEN:
|
|
|
|
{
|
|
|
|
hsize_t nelmts;
|
|
|
|
hid_t memb;
|
|
|
|
|
|
|
|
/* get the VL sequences's base datatype for each element */
|
|
|
|
memb = H5Tget_super(tid);
|
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2012-07-26 21:32:12 +08:00
|
|
|
mem = ((unsigned char*)_mem) + block_index * size;
|
2012-07-26 06:17:48 +08:00
|
|
|
/* Get the number of sequence elements */
|
|
|
|
nelmts = ((hvl_t *) mem)->len;
|
|
|
|
|
|
|
|
/* dump the array element */
|
2013-09-06 04:44:14 +08:00
|
|
|
if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) {
|
|
|
|
H5Tclose(memb);
|
2012-07-26 06:17:48 +08:00
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed");
|
2013-09-06 04:44:14 +08:00
|
|
|
}
|
2012-07-26 06:17:48 +08:00
|
|
|
}
|
|
|
|
H5Tclose(memb);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case H5T_REFERENCE:
|
|
|
|
{
|
2013-02-01 04:51:23 +08:00
|
|
|
if (size == H5R_DSET_REG_REF_BUF_SIZE) {
|
|
|
|
/* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */
|
2012-07-26 06:17:48 +08:00
|
|
|
if (region_output) {
|
|
|
|
/* region data */
|
|
|
|
hid_t region_id, region_space;
|
|
|
|
H5S_sel_type region_type;
|
|
|
|
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2012-07-26 21:32:12 +08:00
|
|
|
mem = ((unsigned char*)_mem) + block_index * size;
|
2012-07-26 06:17:48 +08:00
|
|
|
region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem);
|
|
|
|
if (region_id >= 0) {
|
|
|
|
region_space = H5Rget_region(container, H5R_DATASET_REGION, mem);
|
|
|
|
if (region_space >= 0) {
|
|
|
|
region_type = H5Sget_select_type(region_space);
|
|
|
|
if(region_type == H5S_SEL_POINTS)
|
|
|
|
render_bin_output_region_points(region_space, region_id, stream, container);
|
|
|
|
else
|
|
|
|
render_bin_output_region_blocks(region_space, region_id, stream, container);
|
|
|
|
H5Sclose(region_space);
|
|
|
|
} /* end if (region_space >= 0) */
|
|
|
|
H5Dclose(region_id);
|
|
|
|
} /* end if (region_id >= 0) */
|
|
|
|
}
|
|
|
|
} /* end if (region_output... */
|
|
|
|
}
|
2013-02-01 04:51:23 +08:00
|
|
|
else if (size == H5R_OBJ_REF_BUF_SIZE) {
|
|
|
|
/* if (H5Tequal(tid, H5T_STD_REF_OBJ)) */
|
2012-07-26 06:17:48 +08:00
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
for (block_index = 0; block_index < block_nelmts; block_index++) {
|
2012-07-26 21:32:12 +08:00
|
|
|
mem = ((unsigned char*)_mem) + block_index * size;
|
2012-07-26 06:17:48 +08:00
|
|
|
if (size != HDfwrite(mem, sizeof(char), size, stream))
|
|
|
|
H5E_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
|
|
|
}
|
2009-09-04 22:50:13 +08:00
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print the data values from a dataset referenced by region blocks.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type blocks.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns FAIL if there was an error, otherwise SUCEED
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
int
|
2010-08-13 05:11:00 +08:00
|
|
|
render_bin_output_region_data_blocks(hid_t region_id, FILE *stream,
|
|
|
|
hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
hsize_t *start = NULL;
|
|
|
|
hsize_t *count = NULL;
|
2012-02-23 05:58:50 +08:00
|
|
|
hsize_t numelem;
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t total_size[H5S_MAX_RANK];
|
|
|
|
int jndx;
|
2013-02-02 09:53:32 +08:00
|
|
|
size_t type_size;
|
2010-08-10 02:15:37 +08:00
|
|
|
hid_t mem_space = -1;
|
|
|
|
void *region_buf = NULL;
|
|
|
|
int blkndx;
|
|
|
|
hid_t sid1 = -1;
|
2010-10-21 21:08:44 +08:00
|
|
|
int ret_value = SUCCEED;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Get the dataspace of the dataset */
|
|
|
|
if((sid1 = H5Dget_space(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
|
|
|
|
|
|
|
|
/* find the dimensions of each data space from the block coordinates */
|
|
|
|
numelem = 1;
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1;
|
|
|
|
numelem = dims1[jndx] * numelem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create dataspace for reading buffer */
|
|
|
|
if((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
|
|
|
|
|
|
|
if((type_size = H5Tget_size(type_id)) == 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
2012-05-26 01:39:07 +08:00
|
|
|
if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL)
|
2010-08-10 02:15:37 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer");
|
|
|
|
|
|
|
|
/* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */
|
|
|
|
/* 1 2 n 1 2 n */
|
|
|
|
if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start");
|
|
|
|
|
|
|
|
if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count");
|
|
|
|
|
|
|
|
for (blkndx = 0; blkndx < nblocks; blkndx++) {
|
|
|
|
for (jndx = 0; jndx < ndims; jndx++) {
|
|
|
|
start[jndx] = ptdata[jndx + blkndx * ndims * 2];
|
|
|
|
count[jndx] = dims1[jndx];
|
|
|
|
}
|
|
|
|
|
|
|
|
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
|
2013-09-06 04:44:14 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0)
|
2013-09-06 04:44:14 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0)
|
2013-09-06 04:44:14 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2013-09-06 04:44:14 +08:00
|
|
|
if(render_bin_output(stream, container, type_id, (char*)region_buf, numelem) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data region failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
/* Render the region data element end */
|
2010-08-10 02:15:37 +08:00
|
|
|
} /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */
|
|
|
|
|
|
|
|
done:
|
|
|
|
HDfree(start);
|
|
|
|
HDfree(count);
|
|
|
|
HDfree(region_buf);
|
|
|
|
HDfree(dims1);
|
|
|
|
|
|
|
|
if(H5Sclose(mem_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
if(H5Sclose(sid1) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
|
|
|
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset referenced by region blocks.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to dump a region reference using blocks.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns False if ERROR, otherwise True
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
hbool_t
|
2010-08-10 02:15:37 +08:00
|
|
|
render_bin_output_region_blocks(hid_t region_space, hid_t region_id,
|
2010-08-13 05:11:00 +08:00
|
|
|
FILE *stream, hid_t container)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
HERR_INIT(hbool_t, TRUE)
|
2013-02-02 09:53:32 +08:00
|
|
|
hssize_t snblocks;
|
|
|
|
hsize_t nblocks;
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t alloc_size;
|
2013-02-02 09:53:32 +08:00
|
|
|
hsize_t *ptdata;
|
2010-08-10 02:15:37 +08:00
|
|
|
int ndims;
|
|
|
|
hid_t dtype;
|
|
|
|
hid_t type_id;
|
|
|
|
|
2013-02-02 09:53:32 +08:00
|
|
|
if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0)
|
2010-08-10 02:15:37 +08:00
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed");
|
2013-02-02 09:53:32 +08:00
|
|
|
nblocks = (hsize_t)snblocks;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
/* Print block information */
|
|
|
|
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
|
|
|
|
|
|
|
alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]);
|
2012-02-24 03:08:09 +08:00
|
|
|
HDassert(alloc_size == (hsize_t) ((size_t) alloc_size)); /*check for overflow*/
|
2012-02-23 05:58:50 +08:00
|
|
|
if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) == NULL)
|
2010-08-10 02:15:37 +08:00
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "Could not allocate buffer for ptdata");
|
|
|
|
|
|
|
|
H5_CHECK_OVERFLOW(nblocks, hssize_t, hsize_t);
|
|
|
|
if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Rget_select_hyper_blocklist failed");
|
|
|
|
|
|
|
|
if((dtype = H5Dget_type(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
|
|
|
|
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
|
|
|
|
|
2010-08-13 05:11:00 +08:00
|
|
|
render_bin_output_region_data_blocks(region_id, stream, container, ndims,
|
|
|
|
type_id, nblocks, ptdata);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
done:
|
2012-02-23 05:58:50 +08:00
|
|
|
HDfree(ptdata);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
if(H5Tclose(type_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
if(H5Tclose(dtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
H5_LEAVE(TRUE)
|
|
|
|
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print the data values from a dataset referenced by region points.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to print the data in a region reference of type points.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns FAIL on error, otherwise SUCCEED
|
|
|
|
*
|
|
|
|
* Parameters Description:
|
|
|
|
* h5tools_str_t *buffer is the string into which to render
|
|
|
|
* size_t ncols
|
|
|
|
* int ndims is the number of dimensions of the region element
|
|
|
|
* hssize_t npoints is the number of points in the region
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2013-07-31 01:04:23 +08:00
|
|
|
int
|
2010-08-10 02:15:37 +08:00
|
|
|
render_bin_output_region_data_points(hid_t region_space, hid_t region_id,
|
|
|
|
FILE *stream, hid_t container,
|
2013-02-02 09:53:32 +08:00
|
|
|
int ndims, hid_t type_id, hssize_t npoints)
|
2010-08-13 05:11:00 +08:00
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
hsize_t *dims1 = NULL;
|
|
|
|
int type_size;
|
|
|
|
hid_t mem_space = -1;
|
|
|
|
void *region_buf = NULL;
|
2010-10-21 21:08:44 +08:00
|
|
|
int ret_value = SUCCEED;
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
if((type_size = H5Tget_size(type_id)) == 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_size failed");
|
|
|
|
|
2012-05-26 01:39:07 +08:00
|
|
|
if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL)
|
2010-08-10 02:15:37 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims");
|
|
|
|
|
|
|
|
dims1[0] = npoints;
|
|
|
|
if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed");
|
|
|
|
|
|
|
|
if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
|
2012-07-26 06:17:48 +08:00
|
|
|
if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0)
|
2013-09-06 04:44:14 +08:00
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
2013-09-06 04:44:14 +08:00
|
|
|
if(render_bin_output(stream, container, type_id, (char*)region_buf, npoints) < 0)
|
|
|
|
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "render_bin_output of data points failed");
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
HDfree(region_buf);
|
|
|
|
HDfree(dims1);
|
|
|
|
|
|
|
|
if(H5Sclose(mem_space) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed");
|
2010-10-21 21:08:44 +08:00
|
|
|
|
2010-08-10 02:15:37 +08:00
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Audience: Public
|
|
|
|
* Chapter: H5Tools Library
|
|
|
|
* Purpose: Print some values from a dataset referenced by region points.
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This is a special case subfunction to dump a region reference using points.
|
|
|
|
*
|
|
|
|
* Return:
|
|
|
|
* The function returns False if the last dimension has been reached, otherwise True
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
hbool_t
|
2010-08-10 02:15:37 +08:00
|
|
|
render_bin_output_region_points(hid_t region_space, hid_t region_id,
|
2010-08-13 05:11:00 +08:00
|
|
|
FILE *stream, hid_t container)
|
|
|
|
{
|
2010-08-10 02:15:37 +08:00
|
|
|
HERR_INIT(hbool_t, TRUE)
|
|
|
|
hssize_t npoints;
|
|
|
|
int ndims;
|
|
|
|
hid_t dtype;
|
|
|
|
hid_t type_id;
|
|
|
|
|
|
|
|
if((npoints = H5Sget_select_elem_npoints(region_space)) <= 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed");
|
|
|
|
|
|
|
|
/* Allocate space for the dimension array */
|
|
|
|
if((ndims = H5Sget_simple_extent_ndims(region_space)) < 0)
|
|
|
|
H5E_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
|
|
|
|
|
|
|
|
if((dtype = H5Dget_type(region_id)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Dget_type failed");
|
|
|
|
|
|
|
|
if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0)
|
|
|
|
HGOTO_ERROR(FALSE, H5E_tools_min_id_g, "H5Tget_native_type failed");
|
|
|
|
|
|
|
|
render_bin_output_region_data_points(region_space, region_id,
|
2013-02-02 09:53:32 +08:00
|
|
|
stream, container, ndims, type_id, npoints);
|
2010-08-10 02:15:37 +08:00
|
|
|
|
|
|
|
done:
|
|
|
|
if(H5Tclose(type_id) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
if(H5Tclose(dtype) < 0)
|
|
|
|
HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed");
|
|
|
|
|
|
|
|
H5_LEAVE(ret_value)
|
|
|
|
CATCH
|
|
|
|
return ret_value;
|
|
|
|
}
|
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_is_zero
|
|
|
|
*
|
|
|
|
* Purpose: Determines if memory is initialized to all zero bytes.
|
|
|
|
*
|
|
|
|
* Return: TRUE if all bytes are zero; FALSE otherwise
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
hbool_t
|
|
|
|
h5tools_is_zero(const void *_mem, size_t size)
|
2009-09-04 22:50:13 +08:00
|
|
|
{
|
|
|
|
const unsigned char *mem = (const unsigned char *) _mem;
|
2006-08-03 07:41:53 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
while (size-- > 0)
|
|
|
|
if (mem[size])
|
|
|
|
return FALSE;
|
2006-06-26 22:41:59 +08:00
|
|
|
|
2009-09-04 22:50:13 +08:00
|
|
|
return TRUE;
|
2006-06-26 22:41:59 +08:00
|
|
|
}
|
|
|
|
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* Function: h5tools_is_obj_same
|
|
|
|
*
|
|
|
|
* Purpose: Check if two given object IDs or link names point to the same object.
|
|
|
|
*
|
|
|
|
* Parameters:
|
|
|
|
* hid_t loc_id1: location of the first object
|
|
|
|
* char *name1: link name of the first object.
|
|
|
|
* Use "." or NULL if loc_id1 is the object to be compared.
|
|
|
|
* hid_t loc_id2: location of the second object
|
|
|
|
* char *name1: link name of the first object.
|
|
|
|
* Use "." or NULL if loc_id2 is the object to be compared.
|
|
|
|
*
|
|
|
|
* Return: TRUE if it is the same object; FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Programmer: Peter Cao
|
|
|
|
* 4/27/2011
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
hbool_t
|
|
|
|
h5tools_is_obj_same(hid_t loc_id1, const char *name1,
|
2011-05-04 01:56:23 +08:00
|
|
|
hid_t loc_id2, const char *name2)
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
{
|
|
|
|
H5O_info_t oinfo1, oinfo2;
|
|
|
|
hbool_t ret_val = 0;
|
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
if ( name1 && HDstrcmp(name1, "."))
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info_by_name(loc_id1, name1, &oinfo1, H5P_DEFAULT);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
else
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info(loc_id1, &oinfo1);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
2012-02-23 05:58:50 +08:00
|
|
|
if ( name2 && HDstrcmp(name2, "."))
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info_by_name(loc_id2, name2, &oinfo2, H5P_DEFAULT);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
else
|
2011-05-04 01:56:23 +08:00
|
|
|
H5Oget_info(loc_id2, &oinfo2);
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
|
|
|
if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr)
|
2011-05-04 01:56:23 +08:00
|
|
|
ret_val = 1;
|
[svn-r20676] Purpose:
- HDFFV-5928 - GMQS: h5diff problem and improvement on comparsing the same objects
Description:
Fixed:
1) adding h5tools_is_obj_same() function to check if two given IDs or paths point to the same object. This function can be very useful for other tools and applications.
2) using h5tools_is_obj_same() at h5diff() and diff() in h5diff.c. If two paths point to the same object, there is no need to check the details of the object since we know there is no difference. The fix will increase the performance by skipping the content comparison. It also fixed the problem of reporting difference for some cases of comparing the same file, e.g. empty files or files with incomparable objects the same file.
Test update:
Updat prvious test cases (171, 172, 530) affected by this fix, so they
still perfrom originally intended testing without bypassing.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), linew (solaris-BE), cmake
2011-04-30 01:02:31 +08:00
|
|
|
|
|
|
|
return ret_val;
|
|
|
|
}
|
|
|
|
|