2002-10-15 12:12:42 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2002-10-15 12:12:42 +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. *
|
2002-10-15 12:12:42 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
2001-02-23 05:53:30 +08:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "h5dump.h"
|
2012-02-18 05:41:58 +08:00
|
|
|
|
#include "h5dump_ddl.h"
|
|
|
|
|
#include "h5dump_xml.h"
|
2004-06-08 00:40:25 +08:00
|
|
|
|
|
2010-05-12 04:10:25 +08:00
|
|
|
|
/* Name of tool */
|
|
|
|
|
#define PROGRAMNAME "h5dump"
|
2001-02-25 06:49:37 +08:00
|
|
|
|
|
2006-06-29 03:34:08 +08:00
|
|
|
|
static const char *driver = NULL; /* The driver to open the file with. */
|
2008-11-01 02:22:19 +08:00
|
|
|
|
const char *outfname=NULL;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static int doxml = 0;
|
|
|
|
|
static int useschema = 1;
|
|
|
|
|
static const char *xml_dtd_uri = NULL;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
|
|
|
|
/* module-scoped variables for XML option */
|
2011-08-11 04:48:05 +08:00
|
|
|
|
#define DEFAULT_XSD "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd"
|
2013-06-21 01:39:49 +08:00
|
|
|
|
#define DEFAULT_DTD "http://www.hdfgroup.org/HDF5/XML/DTD/HDF5-File.dtd"
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* Standard DDL output */
|
|
|
|
|
static const dump_functions ddl_function_table = {
|
|
|
|
|
dump_group,
|
|
|
|
|
dump_named_datatype,
|
|
|
|
|
dump_dataset,
|
|
|
|
|
dump_dataspace,
|
|
|
|
|
dump_datatype,
|
|
|
|
|
dump_attr_cb,
|
|
|
|
|
dump_data
|
2001-02-23 05:53:30 +08:00
|
|
|
|
};
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* XML output */
|
|
|
|
|
static const dump_functions xml_function_table = {
|
|
|
|
|
xml_dump_group,
|
|
|
|
|
xml_dump_named_datatype,
|
|
|
|
|
xml_dump_dataset,
|
|
|
|
|
xml_dump_dataspace,
|
|
|
|
|
xml_dump_datatype,
|
|
|
|
|
xml_dump_attr,
|
|
|
|
|
xml_dump_data
|
2001-02-23 05:53:30 +08:00
|
|
|
|
};
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* internal functions */
|
|
|
|
|
static void init_prefix(char **prfx, size_t prfx_len);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
|
|
|
|
/* a structure for handling the order command-line parameters come in */
|
|
|
|
|
struct handler_t {
|
2008-10-16 11:52:16 +08:00
|
|
|
|
void (*func)(hid_t, const char *, void *, int, const char *);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
char *obj;
|
|
|
|
|
struct subset_t *subset_info;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Command-line options: The user can specify short or long-named
|
|
|
|
|
* parameters. The long-named ones can be partially spelled. When
|
|
|
|
|
* adding more, make sure that they don't clash with each other.
|
|
|
|
|
*/
|
2011-04-30 02:38:41 +08:00
|
|
|
|
/* The following initialization makes use of C language cancatenating */
|
|
|
|
|
/* "xxx" "yyy" into "xxxyyy". */
|
2013-08-13 05:58:31 +08:00
|
|
|
|
static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RECM:O*N:";
|
2001-02-23 05:53:30 +08:00
|
|
|
|
static struct long_options l_opts[] = {
|
|
|
|
|
{ "help", no_arg, 'h' },
|
|
|
|
|
{ "hel", no_arg, 'h' },
|
2012-07-13 04:30:30 +08:00
|
|
|
|
{ "contents", optional_arg, 'n' },
|
2004-06-08 00:40:25 +08:00
|
|
|
|
{ "properties", no_arg, 'p' },
|
2013-08-23 03:57:31 +08:00
|
|
|
|
{ "superblock", no_arg, 'B' },
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{ "boot-block", no_arg, 'B' },
|
|
|
|
|
{ "boot-bloc", no_arg, 'B' },
|
|
|
|
|
{ "boot-blo", no_arg, 'B' },
|
|
|
|
|
{ "boot-bl", no_arg, 'B' },
|
|
|
|
|
{ "boot-b", no_arg, 'B' },
|
|
|
|
|
{ "boot", no_arg, 'B' },
|
|
|
|
|
{ "boo", no_arg, 'B' },
|
|
|
|
|
{ "bo", no_arg, 'B' },
|
|
|
|
|
{ "header", no_arg, 'H' },
|
|
|
|
|
{ "heade", no_arg, 'H' },
|
|
|
|
|
{ "head", no_arg, 'H' },
|
|
|
|
|
{ "hea", no_arg, 'H' },
|
|
|
|
|
{ "object-ids", no_arg, 'i' },
|
|
|
|
|
{ "object-id", no_arg, 'i' },
|
|
|
|
|
{ "object-i", no_arg, 'i' },
|
|
|
|
|
{ "object", no_arg, 'i' },
|
|
|
|
|
{ "objec", no_arg, 'i' },
|
|
|
|
|
{ "obje", no_arg, 'i' },
|
|
|
|
|
{ "obj", no_arg, 'i' },
|
|
|
|
|
{ "ob", no_arg, 'i' },
|
|
|
|
|
{ "version", no_arg, 'V' },
|
|
|
|
|
{ "versio", no_arg, 'V' },
|
|
|
|
|
{ "versi", no_arg, 'V' },
|
|
|
|
|
{ "vers", no_arg, 'V' },
|
|
|
|
|
{ "ver", no_arg, 'V' },
|
|
|
|
|
{ "ve", no_arg, 'V' },
|
|
|
|
|
{ "attribute", require_arg, 'a' },
|
|
|
|
|
{ "attribut", require_arg, 'a' },
|
|
|
|
|
{ "attribu", require_arg, 'a' },
|
|
|
|
|
{ "attrib", require_arg, 'a' },
|
|
|
|
|
{ "attri", require_arg, 'a' },
|
|
|
|
|
{ "attr", require_arg, 'a' },
|
|
|
|
|
{ "att", require_arg, 'a' },
|
|
|
|
|
{ "at", require_arg, 'a' },
|
|
|
|
|
{ "block", require_arg, 'k' },
|
|
|
|
|
{ "bloc", require_arg, 'k' },
|
|
|
|
|
{ "blo", require_arg, 'k' },
|
|
|
|
|
{ "bl", require_arg, 'k' },
|
|
|
|
|
{ "count", require_arg, 'c' },
|
|
|
|
|
{ "coun", require_arg, 'c' },
|
|
|
|
|
{ "cou", require_arg, 'c' },
|
|
|
|
|
{ "co", require_arg, 'c' },
|
|
|
|
|
{ "dataset", require_arg, 'd' },
|
|
|
|
|
{ "datase", require_arg, 'd' },
|
|
|
|
|
{ "datas", require_arg, 'd' },
|
|
|
|
|
{ "datatype", require_arg, 't' },
|
|
|
|
|
{ "datatyp", require_arg, 't' },
|
|
|
|
|
{ "dataty", require_arg, 't' },
|
|
|
|
|
{ "datat", require_arg, 't' },
|
2001-08-01 01:20:53 +08:00
|
|
|
|
{ "filedriver", require_arg, 'f' },
|
|
|
|
|
{ "filedrive", require_arg, 'f' },
|
|
|
|
|
{ "filedriv", require_arg, 'f' },
|
|
|
|
|
{ "filedri", require_arg, 'f' },
|
|
|
|
|
{ "filedr", require_arg, 'f' },
|
|
|
|
|
{ "filed", require_arg, 'f' },
|
|
|
|
|
{ "file", require_arg, 'f' },
|
|
|
|
|
{ "fil", require_arg, 'f' },
|
|
|
|
|
{ "fi", require_arg, 'f' },
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{ "group", require_arg, 'g' },
|
|
|
|
|
{ "grou", require_arg, 'g' },
|
|
|
|
|
{ "gro", require_arg, 'g' },
|
|
|
|
|
{ "gr", require_arg, 'g' },
|
2013-02-05 04:15:59 +08:00
|
|
|
|
{ "output", optional_arg, 'o' },
|
|
|
|
|
{ "outpu", optional_arg, 'o' },
|
|
|
|
|
{ "outp", optional_arg, 'o' },
|
|
|
|
|
{ "out", optional_arg, 'o' },
|
|
|
|
|
{ "ou", optional_arg, 'o' },
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{ "soft-link", require_arg, 'l' },
|
|
|
|
|
{ "soft-lin", require_arg, 'l' },
|
|
|
|
|
{ "soft-li", require_arg, 'l' },
|
|
|
|
|
{ "soft-l", require_arg, 'l' },
|
|
|
|
|
{ "soft", require_arg, 'l' },
|
|
|
|
|
{ "sof", require_arg, 'l' },
|
|
|
|
|
{ "start", require_arg, 's' },
|
|
|
|
|
{ "star", require_arg, 's' },
|
|
|
|
|
{ "sta", require_arg, 's' },
|
2001-03-22 06:53:34 +08:00
|
|
|
|
{ "stride", require_arg, 'S' },
|
|
|
|
|
{ "strid", require_arg, 'S' },
|
2003-05-01 06:37:06 +08:00
|
|
|
|
{ "string", no_arg, 'r' },
|
|
|
|
|
{ "strin", no_arg, 'r' },
|
2003-07-30 05:24:21 +08:00
|
|
|
|
{ "use-dtd", no_arg, 'u' },
|
|
|
|
|
{ "use-dt", no_arg, 'u' },
|
|
|
|
|
{ "use-d", no_arg, 'u' },
|
|
|
|
|
{ "use-", no_arg, 'u' },
|
|
|
|
|
{ "use", no_arg, 'u' },
|
|
|
|
|
{ "us", no_arg, 'u' },
|
|
|
|
|
{ "u", no_arg, 'u' },
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{ "width", require_arg, 'w' },
|
|
|
|
|
{ "widt", require_arg, 'w' },
|
|
|
|
|
{ "wid", require_arg, 'w' },
|
|
|
|
|
{ "wi", require_arg, 'w' },
|
|
|
|
|
{ "xml-dtd", require_arg, 'D' },
|
|
|
|
|
{ "xml-dt", require_arg, 'D' },
|
|
|
|
|
{ "xml-d", require_arg, 'D' },
|
2003-07-30 05:24:21 +08:00
|
|
|
|
{ "xml-ns", require_arg, 'X' },
|
|
|
|
|
{ "xml-n", require_arg, 'X' },
|
|
|
|
|
{ "xml", no_arg, 'x' },
|
|
|
|
|
{ "xm", no_arg, 'x' },
|
2013-06-27 05:04:20 +08:00
|
|
|
|
{ "onlyattr", optional_arg, 'A' },
|
2006-09-20 05:22:57 +08:00
|
|
|
|
{ "escape", no_arg, 'e' },
|
|
|
|
|
{ "noindex", no_arg, 'y' },
|
2008-10-30 04:11:51 +08:00
|
|
|
|
{ "binary", optional_arg, 'b' },
|
2006-09-20 05:22:57 +08:00
|
|
|
|
{ "form", require_arg, 'F' },
|
2007-10-02 04:54:01 +08:00
|
|
|
|
{ "sort_by", require_arg, 'q' },
|
|
|
|
|
{ "sort_order", require_arg, 'z' },
|
2008-05-06 04:06:22 +08:00
|
|
|
|
{ "format", require_arg, 'm' },
|
2009-09-04 22:50:13 +08:00
|
|
|
|
{ "region", no_arg, 'R' },
|
2011-03-01 04:25:25 +08:00
|
|
|
|
{ "enable-error-stack", no_arg, 'E' },
|
2011-04-30 02:38:41 +08:00
|
|
|
|
{ "packed-bits", require_arg, 'M' },
|
2012-02-13 22:18:09 +08:00
|
|
|
|
{ "no-compact-subset", no_arg, 'C' },
|
2013-02-05 04:15:59 +08:00
|
|
|
|
{ "ddl", optional_arg, 'O' },
|
2013-08-20 00:02:29 +08:00
|
|
|
|
{ "any_path", require_arg, 'N' },
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{ NULL, 0, '\0' }
|
|
|
|
|
};
|
|
|
|
|
|
2004-02-02 11:32:41 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: leave
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Shutdown MPI & HDF5 and call exit()
|
|
|
|
|
*
|
|
|
|
|
* Return: Does not return
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Quincey Koziol
|
|
|
|
|
* Saturday, 31. January 2004
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
leave(int ret)
|
|
|
|
|
{
|
2004-02-05 06:43:00 +08:00
|
|
|
|
h5tools_close();
|
|
|
|
|
|
2012-02-24 23:45:54 +08:00
|
|
|
|
HDexit(ret);
|
2004-02-02 11:32:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-02-23 05:53:30 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: usage
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Print the usage message about dumper
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2001-02-25 06:49:37 +08:00
|
|
|
|
usage(const char *prog)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2013-01-23 04:43:12 +08:00
|
|
|
|
FLUSHSTREAM(rawoutstream);
|
|
|
|
|
PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] files\n", prog);
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " OPTIONS\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- File Options ---------------\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -n, --contents Print a list of the file contents and exit\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Optional value 1 also prints attributes.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -B, --superblock Print the content of the super block\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -H, --header Print the header only; no data is displayed\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -f D, --filedriver=D Specify which driver to open the file with\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -o F, --output=F Output raw data into file F\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -b B, --binary=B Binary file output, of form B\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -O F, --ddl=F Output ddl text into file F\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Do not use filename F to suppress ddl display\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- Object Options ---------------\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -a P, --attribute=P Print the specified attribute\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " If an attribute name contains a slash (/), escape the\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " slash with a preceding backslash (\\).\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " (See example section below.)\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -d P, --dataset=P Print the specified dataset\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -g P, --group=P Print the specified group and all members\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -l P, --soft-link=P Print the value(s) of the specified soft link\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -t P, --datatype=P Print the specified named datatype\n");
|
2013-08-13 05:58:31 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -N P, --any_path=P Print any attribute, dataset, group, datatype, or link that matches P\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " P can be the absolute path or just a relative path.\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -A, --onlyattr Print the header and value of attributes\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Optional value 0 suppresses printing attributes.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- Object Property Options ---------------\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -i, --object-ids Print the object ids\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -p, --properties Print dataset filters, storage layout and fill value\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -M L, --packedbits=L Print packed bits as unsigned integers, using mask\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " format L for an integer dataset specified with\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " option -d. L is a list of offset,length values,\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " separated by commas. Offset is the beginning bit in\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " the data value and length is the number of bits of\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " the mask.\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -R, --region Print dataset pointed by region references\n");
|
2013-08-13 03:52:09 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- Formatting Options ---------------\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -e, --escape Escape non printing characters\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -r, --string Print 1-byte integer datasets as ASCII\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -y, --noindex Do not print array indices with the data\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -m T, --format=T Set the floating point output format\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -q Q, --sort_by=Q Sort groups and attributes by index Q\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -z Z, --sort_order=Z Sort groups and attributes by order Z\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " occur.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " --no-compact-subset Disable compact form of subsetting and allow the use\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " of \"[\" in dataset names.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -w N, --width=N Set the number of columns of output. A value of 0 (zero)\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " sets the number of columns to the maximum (65535).\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Default width is 80 columns.\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- XML Options ---------------\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -x, --xml Output in XML using Schema\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -u, --use-dtd Output in XML using DTD\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -D U, --xml-dtd=U Use the DTD or schema at U\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -X S, --xml-ns=S (XML Schema) Use qualified names n the XML\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " \":\": no namespace, default: \"hdf5:\"\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " E.g., to dump a file called `-f', use h5dump -- -f\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- Subsetting Options ---------------\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Subsetting is available by using the following options with a dataset\n");
|
2013-08-23 04:16:45 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " option. Subsetting is done by selecting a hyperslab from the data.\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Thus, the options mirror those for performing a hyperslab selection.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " One of the START, COUNT, STRIDE, or BLOCK parameters are mandatory if you do subsetting.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " The STRIDE, COUNT, and BLOCK parameters are optional and will default to 1 in\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " each dimension. START is optional and will default to 0 in each dimension.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -s START, --start=START Offset of start of subsetting selection\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -S STRIDE, --stride=STRIDE Hyperslab stride\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -c COUNT, --count=COUNT Number of blocks to include in selection\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -k BLOCK, --block=BLOCK Size of block in hyperslab\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " START, COUNT, STRIDE, and BLOCK - is a list of integers the number of which are equal to the\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " number of dimensions in the dataspace being queried\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " (Alternate compact form of subsetting is described in the Reference Manual)\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- Option Argument Conventions ---------------\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " D - is the file driver to use in opening the file. Acceptable values\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " are \"sec2\", \"family\", \"split\", \"multi\", \"direct\", and \"stream\". Without\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " the file driver flag, the file will be opened with each driver in\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " turn and in the order specified above until one driver succeeds\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " in opening the file.\n");
|
2013-08-13 03:52:09 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " See examples below for family, split, and multi driver special file name usage.\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " F - is a filename.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " P - is the full path from the root group to the object.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " N - is an integer greater than 1.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " T - is a string containing the floating point format, e.g '%%.3f'\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " U - is a URI reference (as defined in [IETF RFC 2396],\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " updated by [IETF RFC 2732])\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " B - is the form of binary output: NATIVE for a memory type, FILE for the\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " file type, LE or BE for pre-existing little or big endian types.\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Must be used with -o (output file) and it is recommended that\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " -d (dataset) is used. B is an optional argument, defaults to NATIVE\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Q - is the sort index type. It can be \"creation_order\" or \"name\" (default)\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Z - is the sort order type. It can be \"descending\" or \"ascending\" (default)\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2013-08-01 22:42:30 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "--------------- Examples ---------------\n");
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 1) Attribute foo of the group /bar_none in file quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -a /bar_none/foo quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " Attribute \"high/low\" of the group /bar_none in the file quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -a \"/bar_none/high\\/low\" quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 2) Selecting a subset from dataset /foo in file quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -s \"0,1\" -S \"1,1\" -c \"2,3\" -k \"2,2\" quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 3) Saving dataset 'dset' in file quux.h5 to binary file 'out.bin'\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " using a little-endian type\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -b LE -o out.bin quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 4) Display two packed bits (bits 0-1 and bits 4-6) in the dataset /dset\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /dset -M 0,1,4,3 quux.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 5) Dataset foo in files file1.h5 file2.h5 file3.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo file1.h5 file2.h5 file3.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 6) Dataset foo in split files splitfile-m.h5 splitfile-r.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f split splitfile\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2013-08-13 03:52:09 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 7) Dataset foo in multi files mf-s.h5, mf-b.h5, mf-r.h5, mf-g.h5, mf-l.h5 and mf-o.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f multi mf\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, " 8) Dataset foo in family files fam00000.h5 fam00001.h5 and fam00002.h5\n");
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2013-08-13 04:53:54 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, " h5dump -d /foo -f family fam%%05d.h5\n");
|
2013-08-13 03:52:09 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: table_list_add
|
|
|
|
|
*
|
2010-01-30 12:29:13 +08:00
|
|
|
|
* Purpose: Add a new set of tables
|
2008-10-16 11:52:16 +08:00
|
|
|
|
*
|
|
|
|
|
* Return: index of added table on success, -1 on failure
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Neil Fortner, nfortne2@hdfgroup.org
|
|
|
|
|
* Adapted from trav_addr_add in h5trav.c by Quincey Koziol
|
|
|
|
|
*
|
|
|
|
|
* Date: October 13, 2008
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
ssize_t
|
2008-10-16 11:52:16 +08:00
|
|
|
|
table_list_add(hid_t oid, unsigned long file_no)
|
|
|
|
|
{
|
|
|
|
|
size_t idx; /* Index of table to use */
|
|
|
|
|
find_objs_t info;
|
|
|
|
|
|
|
|
|
|
/* Allocate space if necessary */
|
|
|
|
|
if(table_list.nused == table_list.nalloc) {
|
[svn-r17313] Description:
Bring back various minor code cleanups from the file free space branch
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/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, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.5.8 (amazon) in debug mode
Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-08-11 01:08:27 +08:00
|
|
|
|
void *tmp_ptr;
|
|
|
|
|
|
2008-10-16 11:52:16 +08:00
|
|
|
|
table_list.nalloc = MAX(1, table_list.nalloc * 2);
|
|
|
|
|
if(NULL == (tmp_ptr = HDrealloc(table_list.tables, table_list.nalloc * sizeof(table_list.tables[0]))))
|
|
|
|
|
return -1;
|
|
|
|
|
table_list.tables = tmp_ptr;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
/* Append it */
|
|
|
|
|
idx = table_list.nused++;
|
|
|
|
|
table_list.tables[idx].fileno = file_no;
|
|
|
|
|
table_list.tables[idx].oid = oid;
|
|
|
|
|
if(H5Iinc_ref(oid) < 0) {
|
|
|
|
|
table_list.nused--;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
if(init_objs(oid, &info, &table_list.tables[idx].group_table,
|
2011-05-04 01:56:23 +08:00
|
|
|
|
&table_list.tables[idx].dset_table, &table_list.tables[idx].type_table) < 0) {
|
2008-10-16 11:52:16 +08:00
|
|
|
|
H5Idec_ref(oid);
|
|
|
|
|
table_list.nused--;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef H5DUMP_DEBUG
|
|
|
|
|
dump_tables(&info);
|
|
|
|
|
#endif /* H5DUMP_DEBUG */
|
|
|
|
|
|
|
|
|
|
return((ssize_t) idx);
|
|
|
|
|
} /* end table_list_add() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: table_list_visited
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Check if a table already exists for the specified fileno
|
|
|
|
|
*
|
|
|
|
|
* Return: The index of the matching table, or -1 if no matches found
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Neil Fortner, nfortne2@hdfgroup.org
|
|
|
|
|
* Adapted from trav_addr_visited in h5trav.c by Quincey Koziol
|
|
|
|
|
*
|
|
|
|
|
* Date: October 13, 2008
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
ssize_t
|
2008-10-16 11:52:16 +08:00
|
|
|
|
table_list_visited(unsigned long file_no)
|
|
|
|
|
{
|
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
|
|
|
|
|
|
/* Look for table */
|
|
|
|
|
for(u = 0; u < table_list.nused; u++)
|
|
|
|
|
/* Check for fileno value already in array */
|
|
|
|
|
if(table_list.tables[u].fileno == file_no)
|
|
|
|
|
return((ssize_t) u);
|
|
|
|
|
|
|
|
|
|
/* Didn't find table */
|
|
|
|
|
return(-1);
|
|
|
|
|
} /* end table_list_visited() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: table_list_free
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Frees the table list
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Neil Fortner, nfortne2@hdfgroup.org
|
|
|
|
|
*
|
|
|
|
|
* Date: October 13, 2008
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
table_list_free(void)
|
|
|
|
|
{
|
|
|
|
|
size_t u; /* Local index variable */
|
|
|
|
|
|
|
|
|
|
/* Iterate over tables */
|
|
|
|
|
for(u = 0; u < table_list.nused; u++) {
|
|
|
|
|
/* Release object id */
|
|
|
|
|
if(H5Idec_ref(table_list.tables[u].oid) < 0)
|
2010-05-12 04:10:25 +08:00
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
|
|
|
|
/* Free each table */
|
|
|
|
|
free_table(table_list.tables[u].group_table);
|
2011-03-09 21:57:41 +08:00
|
|
|
|
HDfree(table_list.tables[u].group_table);
|
2008-10-16 11:52:16 +08:00
|
|
|
|
free_table(table_list.tables[u].dset_table);
|
2011-03-09 21:57:41 +08:00
|
|
|
|
HDfree(table_list.tables[u].dset_table);
|
2008-10-16 11:52:16 +08:00
|
|
|
|
free_table(table_list.tables[u].type_table);
|
2011-03-09 21:57:41 +08:00
|
|
|
|
HDfree(table_list.tables[u].type_table);
|
2008-10-16 11:52:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free the table list */
|
|
|
|
|
HDfree(table_list.tables);
|
|
|
|
|
table_list.tables = NULL;
|
|
|
|
|
table_list.nalloc = table_list.nused = 0;
|
|
|
|
|
} /* end table_list_free() */
|
|
|
|
|
|
2001-02-23 05:53:30 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: set_binary_form
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: set the binary form of output by translating from a string input
|
|
|
|
|
* parameter to a integer return value
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: integer form of binary output or -1 if none found
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Pedro Vicente Nunes
|
|
|
|
|
* June 28, 2006
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static int
|
|
|
|
|
set_binary_form(const char *form)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
int bform = -1;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if (HDstrcmp(form,"NATIVE") == 0 || HDstrcmp(form,"MEMORY") == 0) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* native form */
|
|
|
|
|
bform = 0;
|
|
|
|
|
}
|
2012-03-03 05:30:30 +08:00
|
|
|
|
else if (HDstrcmp(form,"FILE") == 0) /* file type form */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
bform = 1;
|
2012-03-03 05:30:30 +08:00
|
|
|
|
else if (HDstrcmp(form,"LE") == 0) /* convert to little endian */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
bform = 2;
|
2012-03-03 05:30:30 +08:00
|
|
|
|
else if (HDstrcmp(form,"BE") == 0) /* convert to big endian */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
bform = 3;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
return bform;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: set_sort_by
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: set the "by" form of sorting by translating from a string input
|
|
|
|
|
* parameter to a H5_index_t return value
|
|
|
|
|
* current sort values are [creation_order | name]
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: H5_index_t form of sort or H5_INDEX_UNKNOWN if none found
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Pedro Vicente Nunes
|
|
|
|
|
* October 1, 2007
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static H5_index_t
|
|
|
|
|
set_sort_by(const char *form)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
H5_index_t idx_type = H5_INDEX_UNKNOWN;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if (HDstrcmp(form,"name")==0) /* H5_INDEX_NAME */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
idx_type = H5_INDEX_NAME;
|
2012-03-03 05:30:30 +08:00
|
|
|
|
else if (HDstrcmp(form,"creation_order")==0) /* H5_INDEX_CRT_ORDER */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
idx_type = H5_INDEX_CRT_ORDER;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
return idx_type;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: set_sort_order
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: set the order of sorting by translating from a string input
|
|
|
|
|
* parameter to a H5_iter_order_t return value
|
|
|
|
|
* current order values are [ascending | descending ]
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: H5_iter_order_t form of order or H5_ITER_UNKNOWN if none found
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Pedro Vicente Nunes
|
|
|
|
|
* October 1, 2007
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Modifications:
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static H5_iter_order_t
|
|
|
|
|
set_sort_order(const char *form)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
H5_iter_order_t iter_order = H5_ITER_UNKNOWN;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if (HDstrcmp(form,"ascending")==0) /* H5_ITER_INC */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
iter_order = H5_ITER_INC;
|
2012-03-03 05:30:30 +08:00
|
|
|
|
else if (HDstrcmp(form,"descending")==0) /* H5_ITER_DEC */
|
2012-02-18 05:41:58 +08:00
|
|
|
|
iter_order = H5_ITER_DEC;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
return iter_order;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: parse_hsize_list
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: Parse a list of comma or space separated integers and return
|
|
|
|
|
* them in a list. The string being passed into this function
|
|
|
|
|
* should be at the start of the list you want to parse. You are
|
|
|
|
|
* responsible for freeing the array returned from here.
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Lists in the so-called "terse" syntax are separated by
|
|
|
|
|
* semicolons (;). The lists themselves can be separated by
|
|
|
|
|
* either commas (,) or white spaces.
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: <none>
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Bill Wendling
|
|
|
|
|
* Tuesday, 6. February 2001
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static void
|
|
|
|
|
parse_hsize_list(const char *h_list, subset_d *d)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
hsize_t *p_list;
|
|
|
|
|
const char *ptr;
|
|
|
|
|
unsigned int size_count = 0;
|
|
|
|
|
unsigned int i = 0;
|
|
|
|
|
unsigned int last_digit = 0;
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (!h_list || !*h_list || *h_list == ';')
|
|
|
|
|
return;
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* count how many integers do we have */
|
|
|
|
|
for (ptr = h_list; ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if (HDisdigit(*ptr)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (!last_digit)
|
|
|
|
|
/* the last read character wasn't a digit */
|
|
|
|
|
size_count++;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_digit = 1;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
last_digit = 0;
|
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (size_count == 0)
|
|
|
|
|
/* there aren't any integers to read */
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* allocate an array for the integers in the list */
|
2012-02-24 22:39:17 +08:00
|
|
|
|
p_list = (hsize_t *)HDcalloc(size_count, sizeof(hsize_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
|
|
for (ptr = h_list; i < size_count && ptr && *ptr && *ptr != ';' && *ptr != ']'; ptr++)
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if(HDisdigit(*ptr)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* we should have an integer now */
|
2012-03-03 05:30:30 +08:00
|
|
|
|
p_list[i++] = (hsize_t)HDatof(ptr);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
2012-03-03 05:30:30 +08:00
|
|
|
|
while (HDisdigit(*ptr))
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* scroll to end of integer */
|
|
|
|
|
ptr++;
|
|
|
|
|
}
|
|
|
|
|
d->data = p_list;
|
|
|
|
|
d->len = size_count;
|
[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
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
return;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: parse_subset_params
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: Parse the so-called "terse" syntax for specifying subsetting
|
|
|
|
|
* parameters.
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: Success: struct subset_t object
|
|
|
|
|
* Failure: NULL
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Bill Wendling
|
|
|
|
|
* Tuesday, 6. February 2001
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
[svn-r14976] Support for external links follow up. The format is to print the target object as part of TARGETPATH, noted with some extra indentation
The previous printing of
LINKCLASS 64
was removed
HDF5 "textlinksrc.h5" {
GROUP "/" {
EXTERNAL_LINK "ext_link1" {
TARGETFILE "textlinktar.h5"
TARGETPATH "dset"
DATASET "dset" {
DATATYPE H5T_STD_I32LE
DATASPACE SIMPLE { ( 6 ) / ( 6 ) }
DATA {
(0): 1, 2, 3, 4, 5, 6
}
}
}
}
}
There is no script test for this behavior so far, because test script uses complete paths that vary from test to test, making not possible to define a valid TARGETFILE in the file
tested: windows, linux, solaris
2008-05-13 03:32:13 +08:00
|
|
|
|
*
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static struct subset_t *
|
|
|
|
|
parse_subset_params(char *dset)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
struct subset_t *s = NULL;
|
|
|
|
|
register char *brace;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
*brace++ = '\0';
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-24 22:39:17 +08:00
|
|
|
|
s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_hsize_list(brace, &s->start);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
while (*brace && *brace != ';')
|
|
|
|
|
brace++;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (*brace) brace++;
|
2007-04-04 03:51:14 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_hsize_list(brace, &s->stride);
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
while (*brace && *brace != ';')
|
|
|
|
|
brace++;
|
2002-02-28 05:52:19 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (*brace) brace++;
|
2002-02-28 05:52:19 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_hsize_list(brace, &s->count);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
while (*brace && *brace != ';')
|
|
|
|
|
brace++;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (*brace) brace++;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_hsize_list(brace, &s->block);
|
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
return s;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: parse_mask_list
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: Parse a list of comma or space separated integers and fill
|
|
|
|
|
* the packed_bits list and counter. The string being passed into this function
|
|
|
|
|
* should be at the start of the list you want to parse.
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: Success: SUCCEED
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Failure: FAIL
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static int
|
|
|
|
|
parse_mask_list(const char *h_list)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
int offset_value;
|
|
|
|
|
int length_value;
|
|
|
|
|
unsigned long long temp_mask;
|
|
|
|
|
const char *ptr = NULL;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* sanity check */
|
|
|
|
|
HDassert(h_list);
|
2007-10-10 03:42:31 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
HDmemset(packed_mask,0,sizeof(packed_mask));
|
2007-10-10 03:42:31 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
packed_bits_num = 0;
|
|
|
|
|
/* scan in pair of offset,length separated by commas. */
|
|
|
|
|
ptr = h_list;
|
|
|
|
|
while (*ptr) {
|
|
|
|
|
/* scan for an offset which is an unsigned int */
|
|
|
|
|
if (!HDisdigit(*ptr)) {
|
|
|
|
|
error_msg("Bad mask list(%s)\n", h_list);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
|
|
|
|
offset_value = HDatoi(ptr);
|
|
|
|
|
if (offset_value < 0 || offset_value >= PACKED_BITS_SIZE_MAX) {
|
|
|
|
|
error_msg("Packed Bit offset value(%d) must be between 0 and %d\n",
|
|
|
|
|
offset_value, PACKED_BITS_SIZE_MAX - 1);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
2006-06-27 22:45:06 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* skip to end of integer */
|
|
|
|
|
while (HDisdigit(*++ptr))
|
|
|
|
|
;
|
|
|
|
|
/* Look for the common separator */
|
|
|
|
|
if (*ptr++ != ',') {
|
|
|
|
|
error_msg("Bad mask list(%s), missing expected comma separator.\n", h_list);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* scan for a length which is a positive int */
|
|
|
|
|
if (!HDisdigit(*ptr)) {
|
|
|
|
|
error_msg("Bad mask list(%s)\n", h_list);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
|
|
|
|
length_value = HDatoi(ptr);
|
|
|
|
|
if (length_value <= 0) {
|
|
|
|
|
error_msg("Packed Bit length value(%d) must be positive.\n", length_value);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
|
|
|
|
if ((offset_value + length_value) > PACKED_BITS_SIZE_MAX){
|
|
|
|
|
error_msg("Packed Bit offset+length value(%d) too large. Max is %d\n",
|
|
|
|
|
offset_value+length_value, PACKED_BITS_SIZE_MAX);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* skip to end of int */
|
|
|
|
|
while (HDisdigit(*++ptr))
|
|
|
|
|
;
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* store the offset,length pair */
|
|
|
|
|
if (packed_bits_num >= PACKED_BITS_MAX) {
|
|
|
|
|
/* too many requests */
|
|
|
|
|
error_msg("Too many masks requested (max. %d). Mask list(%s)\n", PACKED_BITS_MAX, h_list);
|
|
|
|
|
return FAIL;
|
2008-10-16 11:52:16 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
packed_offset[packed_bits_num] = offset_value;
|
|
|
|
|
packed_length[packed_bits_num] = length_value;
|
|
|
|
|
/* create the bit mask by left shift 1's by length, then negate it. */
|
|
|
|
|
/* After packed_mask is calculated, packed_length is not needed but */
|
|
|
|
|
/* keep it for debug purpose. */
|
|
|
|
|
temp_mask = ~0L;
|
|
|
|
|
if(length_value<8*sizeof(unsigned long long)) {
|
|
|
|
|
temp_mask = temp_mask << length_value;
|
|
|
|
|
packed_mask[packed_bits_num] = ~temp_mask;
|
2008-10-16 11:52:16 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
2012-02-18 05:41:58 +08:00
|
|
|
|
packed_mask[packed_bits_num] = temp_mask;
|
|
|
|
|
packed_bits_num++;
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* skip a possible comma separator */
|
|
|
|
|
if (*ptr == ',') {
|
|
|
|
|
if (!(*++ptr)) {
|
|
|
|
|
/* unexpected end of string */
|
|
|
|
|
error_msg("Bad mask list(%s), unexpected end of string.\n", h_list);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
HDassert(packed_bits_num <= PACKED_BITS_MAX);
|
|
|
|
|
if (packed_bits_num == 0) {
|
|
|
|
|
/* got no masks! */
|
|
|
|
|
error_msg("Bad mask list(%s)\n", h_list);
|
|
|
|
|
return FAIL;
|
|
|
|
|
}
|
|
|
|
|
return SUCCEED;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
2001-02-23 05:53:30 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: free_handler
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: Convenience function to free the handler_t structures. Needs a
|
|
|
|
|
* length variable (LEN) to know how many in the array it needs
|
|
|
|
|
* to free
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: Nothing
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Bill Wendling
|
|
|
|
|
* Tuesday, 20. February 2001
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static void
|
2012-02-18 05:41:58 +08:00
|
|
|
|
free_handler(struct handler_t *hand, int len)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-10-18 02:41:42 +08:00
|
|
|
|
int i;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
|
|
|
|
if(hand) {
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
|
if(hand[i].obj) {
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand[i].obj);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
hand[i].obj=NULL;
|
2007-10-05 04:44:07 +08:00
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (hand[i].subset_info) {
|
|
|
|
|
if(hand[i].subset_info->start.data)
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand[i].subset_info->start.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if(hand[i].subset_info->stride.data)
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand[i].subset_info->stride.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if(hand[i].subset_info->count.data)
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand[i].subset_info->count.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if(hand[i].subset_info->block.data)
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand[i].subset_info->block.data);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand[i].subset_info);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
hand[i].subset_info=NULL;
|
|
|
|
|
}
|
2007-08-31 04:03:37 +08:00
|
|
|
|
}
|
2007-10-06 22:54:02 +08:00
|
|
|
|
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(hand);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
2001-02-23 05:53:30 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: parse_command_line
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: Parse the command line for the h5dumper.
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: Success: A pointer to an array of handler_t structures.
|
|
|
|
|
* These contain all the information needed to dump
|
|
|
|
|
* the necessary object.
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Failure: Exits program with EXIT_FAILURE value.
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Bill Wendling
|
|
|
|
|
* Tuesday, 20. February 2001
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2008-09-16 23:52:51 +08:00
|
|
|
|
* Modifications:
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* pvn June, 1, 2006. Add a switch for binary output
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
static struct handler_t *
|
|
|
|
|
parse_command_line(int argc, const char *argv[])
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
struct handler_t *hand = NULL;
|
|
|
|
|
struct handler_t *last_dset = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
int opt;
|
|
|
|
|
int last_was_dset = FALSE;
|
2007-10-10 02:44:26 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* no arguments */
|
|
|
|
|
if (argc == 1) {
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
2007-10-10 02:44:26 +08:00
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* this will be plenty big enough to hold the info */
|
2012-02-24 22:39:17 +08:00
|
|
|
|
if((hand = (struct handler_t *)HDcalloc((size_t)argc, sizeof(struct handler_t)))==NULL) {
|
2012-10-19 03:47:39 +08:00
|
|
|
|
goto error;
|
2007-10-10 02:44:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* parse command line options */
|
|
|
|
|
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
|
|
|
|
|
parse_start:
|
|
|
|
|
switch ((char)opt) {
|
|
|
|
|
case 'R':
|
|
|
|
|
display_region = TRUE;
|
|
|
|
|
region_output = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'B':
|
|
|
|
|
display_bb = TRUE;
|
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'n':
|
|
|
|
|
display_fi = TRUE;
|
|
|
|
|
last_was_dset = FALSE;
|
2012-07-13 04:30:30 +08:00
|
|
|
|
if ( opt_arg != NULL) {
|
|
|
|
|
h5trav_set_verbose(HDatoi(opt_arg));
|
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
break;
|
|
|
|
|
case 'p':
|
|
|
|
|
display_dcpl = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'y':
|
|
|
|
|
display_ai = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'e':
|
|
|
|
|
display_escape = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'H':
|
|
|
|
|
display_data = FALSE;
|
|
|
|
|
display_attr_data = FALSE;
|
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'A':
|
2013-06-27 05:04:20 +08:00
|
|
|
|
if ( opt_arg != NULL) {
|
|
|
|
|
if(0 == HDatoi(opt_arg)) include_attrs = FALSE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
display_data = FALSE;
|
|
|
|
|
display_attr_data = TRUE;
|
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
break;
|
|
|
|
|
case 'i':
|
|
|
|
|
display_oid = TRUE;
|
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'r':
|
|
|
|
|
display_char = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'V':
|
|
|
|
|
print_version(h5tools_getprogname());
|
|
|
|
|
free_handler(hand, argc);
|
|
|
|
|
hand = NULL;
|
|
|
|
|
h5tools_setstatus(EXIT_SUCCESS);
|
|
|
|
|
goto done;
|
|
|
|
|
break;
|
|
|
|
|
case 'w':
|
|
|
|
|
h5tools_nCols = HDatoi(opt_arg);
|
2012-10-19 03:47:39 +08:00
|
|
|
|
if (h5tools_nCols <= 0) {
|
2012-07-10 02:02:24 +08:00
|
|
|
|
h5tools_nCols = 65535;
|
|
|
|
|
}
|
2013-08-13 05:58:31 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'N':
|
|
|
|
|
display_all = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
|
if (!hand[i].func) {
|
|
|
|
|
hand[i].func = handle_paths;
|
|
|
|
|
hand[i].obj = HDstrdup(opt_arg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'a':
|
|
|
|
|
display_all = 0;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
|
if (!hand[i].func) {
|
|
|
|
|
hand[i].func = handle_attributes;
|
|
|
|
|
hand[i].obj = HDstrdup(opt_arg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'd':
|
|
|
|
|
display_all = 0;
|
2007-10-05 00:21:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
|
if (!hand[i].func) {
|
|
|
|
|
hand[i].func = handle_datasets;
|
|
|
|
|
hand[i].obj = HDstrdup(opt_arg);
|
|
|
|
|
hand[i].subset_info = parse_subset_params(hand[i].obj);
|
|
|
|
|
last_dset = &hand[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'f':
|
|
|
|
|
driver = opt_arg;
|
|
|
|
|
break;
|
|
|
|
|
case 'g':
|
|
|
|
|
display_all = 0;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
|
if (!hand[i].func) {
|
|
|
|
|
hand[i].func = handle_groups;
|
|
|
|
|
hand[i].obj = HDstrdup(opt_arg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-10-05 00:21:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 'l':
|
|
|
|
|
display_all = 0;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
|
if (!hand[i].func) {
|
|
|
|
|
hand[i].func = handle_links;
|
|
|
|
|
hand[i].obj = HDstrdup(opt_arg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2007-10-10 03:52:05 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case 't':
|
|
|
|
|
display_all = 0;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
|
if (!hand[i].func) {
|
|
|
|
|
hand[i].func = handle_datatypes;
|
|
|
|
|
hand[i].obj = HDstrdup(opt_arg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
break;
|
2001-03-22 06:53:34 +08:00
|
|
|
|
|
2013-01-23 04:43:12 +08:00
|
|
|
|
case 'O':
|
2013-08-01 00:22:40 +08:00
|
|
|
|
if (h5tools_set_output_file(opt_arg, 0) < 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'o':
|
|
|
|
|
if ( bin_output ) {
|
2013-07-31 01:04:23 +08:00
|
|
|
|
if (h5tools_set_data_output_file(opt_arg, 1) < 0) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
if(display_attr_data && !display_data) {
|
2013-07-31 01:04:23 +08:00
|
|
|
|
if (h5tools_set_attr_output_file(opt_arg, 0) < 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(display_data || display_all) {
|
2013-07-31 01:04:23 +08:00
|
|
|
|
if (h5tools_set_data_output_file(opt_arg, 0) < 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
usingdasho = TRUE;
|
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
outfname = opt_arg;
|
|
|
|
|
break;
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'b':
|
|
|
|
|
if ( opt_arg != NULL) {
|
|
|
|
|
if ( ( bin_form = set_binary_form(opt_arg)) < 0) {
|
|
|
|
|
/* failed to set binary form */
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bin_output = TRUE;
|
|
|
|
|
if (outfname!=NULL) {
|
2013-07-31 01:04:23 +08:00
|
|
|
|
if (h5tools_set_data_output_file(outfname, 1) < 0) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* failed to set output file */
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
last_was_dset = FALSE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'q':
|
|
|
|
|
if ( ( sort_by = set_sort_by(opt_arg)) < 0) {
|
|
|
|
|
/* failed to set "sort by" form */
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'z':
|
|
|
|
|
if ( ( sort_order = set_sort_order(opt_arg)) < 0) {
|
|
|
|
|
/* failed to set "sort order" form */
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2001-03-09 04:22:08 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'M':
|
|
|
|
|
if (!last_was_dset) {
|
|
|
|
|
error_msg("option `-%c' can only be used after --dataset option\n", opt);
|
|
|
|
|
goto error;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (parse_mask_list(opt_arg) != SUCCEED){
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
display_packed_bits = TRUE;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
break;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/** begin XML parameters **/
|
|
|
|
|
case 'x':
|
|
|
|
|
/* select XML output */
|
|
|
|
|
doxml = TRUE;
|
|
|
|
|
useschema = TRUE;
|
|
|
|
|
h5tools_dump_header_format = NULL;
|
|
|
|
|
dump_function_table = &xml_function_table;
|
|
|
|
|
h5tools_nCols = 0;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'u':
|
|
|
|
|
doxml = TRUE;
|
|
|
|
|
useschema = FALSE;
|
|
|
|
|
xmlnsprefix = "";
|
|
|
|
|
h5tools_dump_header_format = NULL;
|
|
|
|
|
dump_function_table = &xml_function_table;
|
|
|
|
|
h5tools_nCols = 0;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
break;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'D':
|
|
|
|
|
/* specify alternative XML DTD or schema */
|
|
|
|
|
/* To Do: check format of this value? */
|
|
|
|
|
xml_dtd_uri = opt_arg;
|
|
|
|
|
h5tools_nCols = 0;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'm':
|
|
|
|
|
/* specify alternative floating point printing format */
|
|
|
|
|
fp_format = opt_arg;
|
|
|
|
|
h5tools_nCols = 0;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
break;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'X':
|
|
|
|
|
/* specify XML namespace (default="hdf5:"), or none */
|
|
|
|
|
/* To Do: check format of this value? */
|
|
|
|
|
if (!useschema) {
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2012-03-03 05:30:30 +08:00
|
|
|
|
if (HDstrcmp(opt_arg,":") == 0) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
xmlnsprefix = "";
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
xmlnsprefix = opt_arg;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
h5tools_nCols = 0;
|
|
|
|
|
break;
|
|
|
|
|
/** end XML parameters **/
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/** begin subsetting parameters **/
|
|
|
|
|
case 's':
|
|
|
|
|
case 'S':
|
|
|
|
|
case 'c':
|
|
|
|
|
case 'k': {
|
|
|
|
|
struct subset_t *s;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (!last_was_dset) {
|
|
|
|
|
error_msg("option `-%c' can only be used after --dataset option\n", opt);
|
|
|
|
|
goto error;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2008-10-16 11:52:16 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (last_dset->subset_info) {
|
|
|
|
|
/*
|
|
|
|
|
* This overrides the "terse" syntax if they actually mixed
|
|
|
|
|
* the two.
|
2008-10-16 11:52:16 +08:00
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
s = last_dset->subset_info;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
2012-02-24 22:39:17 +08:00
|
|
|
|
last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));
|
2012-02-18 05:41:58 +08:00
|
|
|
|
}
|
2003-07-30 05:24:21 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/*
|
|
|
|
|
* slightly convoluted, but...we are only interested in options
|
|
|
|
|
* for subsetting: "--start", "--stride", "--count", and "--block"
|
|
|
|
|
* which can come in any order. If we run out of parameters (EOF)
|
|
|
|
|
* or run into one which isn't a subsetting parameter (NOT s, S,
|
|
|
|
|
* c, or K), then we exit the do-while look, set the subset_info
|
|
|
|
|
* to the structure we've been filling. If we've reached the end
|
|
|
|
|
* of the options, we exit the parsing (goto parse_end) otherwise,
|
|
|
|
|
* since we've "read" the next option, we need to parse it. So we
|
|
|
|
|
* jump to the beginning of the switch statement (goto parse_start).
|
|
|
|
|
*/
|
|
|
|
|
do {
|
|
|
|
|
switch ((char)opt) {
|
|
|
|
|
case 's':
|
|
|
|
|
if (s->start.data) {
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(s->start.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
s->start.data = NULL;
|
|
|
|
|
}
|
|
|
|
|
parse_hsize_list(opt_arg, &s->start);
|
|
|
|
|
break;
|
|
|
|
|
case 'S':
|
|
|
|
|
if (s->stride.data) {
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(s->stride.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
s->stride.data = NULL;
|
|
|
|
|
}
|
|
|
|
|
parse_hsize_list(opt_arg, &s->stride);
|
|
|
|
|
break;
|
|
|
|
|
case 'c':
|
|
|
|
|
if (s->count.data) {
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(s->count.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
s->count.data = NULL;
|
2012-10-18 02:41:42 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_hsize_list(opt_arg, &s->count);
|
|
|
|
|
break;
|
|
|
|
|
case 'k':
|
|
|
|
|
if (s->block.data) {
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDfree(s->block.data);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
s->block.data = NULL;
|
2005-08-26 04:16:40 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_hsize_list(opt_arg, &s->block);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
goto end_collect;
|
2005-08-26 04:16:40 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
} while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF);
|
2001-03-22 06:53:34 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
end_collect:
|
|
|
|
|
last_was_dset = FALSE;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (opt != EOF)
|
|
|
|
|
goto parse_start;
|
|
|
|
|
else
|
|
|
|
|
goto parse_end;
|
2007-08-31 04:03:37 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/** end subsetting parameters **/
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
case 'E':
|
|
|
|
|
enable_error_stack = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'C':
|
|
|
|
|
disable_compact_subset = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
case 'h':
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
free_handler(hand, argc);
|
|
|
|
|
hand = NULL;
|
|
|
|
|
h5tools_setstatus(EXIT_SUCCESS);
|
|
|
|
|
goto done;
|
|
|
|
|
case '?':
|
|
|
|
|
default:
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
2007-03-13 00:36:34 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
}
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
parse_end:
|
|
|
|
|
/* check for file name to be processed */
|
|
|
|
|
if (argc <= opt_ind) {
|
|
|
|
|
error_msg("missing file name\n");
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
done:
|
|
|
|
|
return hand;
|
2007-10-10 04:21:31 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
error:
|
|
|
|
|
if (hand) {
|
|
|
|
|
free_handler(hand, argc);
|
|
|
|
|
hand = NULL;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
return hand;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
2012-10-19 03:47:39 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
2001-02-23 05:53:30 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Function: main
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Purpose: HDF5 dumper
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Return: Success: 0
|
|
|
|
|
* Failure: 1
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Programmer: Ruey-Hsia Li
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
2012-02-18 05:41:58 +08:00
|
|
|
|
* Albert Cheng
|
|
|
|
|
* 30. September 2000
|
|
|
|
|
* Add the -o option--output file for datasets raw data
|
|
|
|
|
*
|
|
|
|
|
* REMcG
|
|
|
|
|
* November 2000
|
|
|
|
|
* Changes to support XML.
|
|
|
|
|
*
|
|
|
|
|
* Bill Wendling
|
|
|
|
|
* Wednesday, 10. January 2001
|
|
|
|
|
* Modified the way command line parameters are interpreted. They go
|
|
|
|
|
* through one function call now (get_option).
|
|
|
|
|
*
|
|
|
|
|
* Bill Wendling
|
|
|
|
|
* Tuesday, 20. February 2001
|
|
|
|
|
* Moved command line parsing to separate function. Made various
|
|
|
|
|
* "display_*" flags global.
|
|
|
|
|
*
|
|
|
|
|
* REMcG
|
|
|
|
|
* August 2003
|
|
|
|
|
* Major upgrade to XML support.
|
|
|
|
|
*
|
|
|
|
|
* Pedro Vicente
|
|
|
|
|
* September 2007
|
|
|
|
|
* list objects in requested order (creation order or alphabetically)
|
2001-02-23 05:53:30 +08:00
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
int
|
|
|
|
|
main(int argc, const char *argv[])
|
2001-02-23 05:53:30 +08:00
|
|
|
|
{
|
2012-02-18 05:41:58 +08:00
|
|
|
|
hid_t fid = -1;
|
|
|
|
|
hid_t gid = -1;
|
|
|
|
|
H5E_auto2_t func;
|
2012-03-13 00:33:15 +08:00
|
|
|
|
H5E_auto2_t tools_func;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
H5O_info_t oi;
|
2012-03-13 00:33:15 +08:00
|
|
|
|
struct handler_t *hand = NULL;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
int i;
|
|
|
|
|
unsigned u;
|
|
|
|
|
void *edata;
|
2012-03-13 00:33:15 +08:00
|
|
|
|
void *tools_edata;
|
2012-02-18 05:41:58 +08:00
|
|
|
|
char *fname = NULL;
|
[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
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
h5tools_setprogname(PROGRAMNAME);
|
|
|
|
|
h5tools_setstatus(EXIT_SUCCESS);
|
|
|
|
|
h5tools_dump_header_format = &h5tools_standardformat;
|
|
|
|
|
dump_function_table = &ddl_function_table;
|
|
|
|
|
dump_indent = 0;
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* Disable error reporting */
|
|
|
|
|
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
|
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
/* Initialize h5tools lib */
|
|
|
|
|
h5tools_init();
|
2012-10-18 02:41:42 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* Disable tools error reporting */
|
|
|
|
|
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
|
|
|
|
|
H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if((hand = parse_command_line(argc, argv))==NULL) {
|
|
|
|
|
goto done;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (bin_output && outfname == NULL) {
|
|
|
|
|
error_msg("binary output requires a file name, use -o <filename>\n");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if (enable_error_stack) {
|
2012-02-18 05:41:58 +08:00
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, func, edata);
|
2012-03-13 00:33:15 +08:00
|
|
|
|
H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
|
|
|
|
|
}
|
2001-02-25 06:49:37 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* Check for conflicting options */
|
|
|
|
|
if (doxml) {
|
|
|
|
|
if (!display_all) {
|
|
|
|
|
error_msg("option \"%s\" not available for XML\n",
|
|
|
|
|
"to display selected objects");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
2012-10-18 02:41:42 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
else if (display_bb) {
|
|
|
|
|
error_msg("option \"%s\" not available for XML\n", "--boot-block");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
2012-10-18 02:41:42 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
else if (display_oid == 1) {
|
|
|
|
|
error_msg("option \"%s\" not available for XML\n", "--object-ids");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
2012-10-18 02:41:42 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
else if (display_char == TRUE) {
|
|
|
|
|
error_msg("option \"%s\" not available for XML\n", "--string");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
2012-10-18 02:41:42 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
else if (usingdasho) {
|
|
|
|
|
error_msg("option \"%s\" not available for XML\n", "--output");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
[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
|
|
|
|
}
|
2012-10-18 02:41:42 +08:00
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
else {
|
|
|
|
|
if (xml_dtd_uri) {
|
|
|
|
|
warn_msg("option \"%s\" only applies with XML: %s\n", "--xml-dtd", xml_dtd_uri);
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
2001-02-25 06:49:37 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if (argc <= opt_ind) {
|
|
|
|
|
error_msg("missing file name\n");
|
|
|
|
|
usage(h5tools_getprogname());
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
2012-07-12 23:38:44 +08:00
|
|
|
|
/* Initialize indexing options */
|
|
|
|
|
h5trav_set_index(sort_by, sort_order);
|
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
while(opt_ind < argc) {
|
|
|
|
|
fname = HDstrdup(argv[opt_ind++]);
|
2001-04-11 03:54:08 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if (fid < 0) {
|
|
|
|
|
error_msg("unable to open file \"%s\"\n", fname);
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* allocate and initialize internal data structure */
|
|
|
|
|
init_prefix(&prefix, prefix_len);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* Prepare to find objects that might be targets of a reference */
|
|
|
|
|
fill_ref_path_table(fid);
|
2001-02-25 06:49:37 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if(doxml) {
|
|
|
|
|
/* initialize XML */
|
|
|
|
|
/* reset prefix! */
|
|
|
|
|
HDstrcpy(prefix, "");
|
|
|
|
|
|
|
|
|
|
/* make sure the URI is initialized to something */
|
|
|
|
|
if (xml_dtd_uri == NULL) {
|
|
|
|
|
if (useschema) {
|
|
|
|
|
xml_dtd_uri = DEFAULT_XSD;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
xml_dtd_uri = DEFAULT_DTD;
|
|
|
|
|
xmlnsprefix = "";
|
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if (useschema && HDstrcmp(xmlnsprefix,"")) {
|
|
|
|
|
error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
[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
|
|
|
|
}
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2002-11-19 00:38:11 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* Get object info for root group */
|
|
|
|
|
if(H5Oget_info_by_name(fid, "/", &oi, H5P_DEFAULT) < 0) {
|
|
|
|
|
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* Initialize object tables */
|
|
|
|
|
if(table_list_add(fid, oi.fileno) < 0) {
|
|
|
|
|
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
group_table = table_list.tables[0].group_table;
|
|
|
|
|
dset_table = table_list.tables[0].dset_table;
|
|
|
|
|
type_table = table_list.tables[0].type_table;
|
|
|
|
|
|
|
|
|
|
/* does there exist unamed committed datatype */
|
|
|
|
|
for (u = 0; u < type_table->nobjs; u++)
|
|
|
|
|
if (!type_table->objs[u].recorded) {
|
|
|
|
|
unamedtype = 1;
|
|
|
|
|
break;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
/* start to dump - display file header information */
|
|
|
|
|
if (!doxml) {
|
|
|
|
|
begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
2012-02-18 05:41:58 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* alternative first element, depending on schema or DTD. */
|
|
|
|
|
if (useschema) {
|
|
|
|
|
if (HDstrcmp(xmlnsprefix,"") == 0) {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTSTREAM(rawoutstream, "<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
|
2012-03-13 00:33:15 +08:00
|
|
|
|
xml_dtd_uri);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* TO DO: make -url option work in this case (may need new option) */
|
|
|
|
|
char *ns;
|
|
|
|
|
char *indx;
|
|
|
|
|
|
|
|
|
|
ns = HDstrdup(xmlnsprefix);
|
|
|
|
|
indx = HDstrrchr(ns,(int)':');
|
|
|
|
|
if (indx) *indx = '\0';
|
|
|
|
|
|
2013-06-21 01:39:49 +08:00
|
|
|
|
PRINTSTREAM(rawoutstream, "<%sHDF5-File xmlns:%s=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\" "
|
2012-03-13 00:33:15 +08:00
|
|
|
|
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
|
|
|
|
|
"xsi:schemaLocation=\"http://hdfgroup.org/HDF5/XML/schema/HDF5-File "
|
|
|
|
|
"http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns);
|
|
|
|
|
HDfree(ns);
|
|
|
|
|
}
|
2012-02-18 05:41:58 +08:00
|
|
|
|
}
|
2011-05-04 01:56:23 +08:00
|
|
|
|
else {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTSTREAM(rawoutstream, "<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n", xml_dtd_uri);
|
|
|
|
|
PRINTVALSTREAM(rawoutstream, "<HDF5-File>\n");
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-30 05:24:21 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if (!doxml) {
|
|
|
|
|
if (display_fi) {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2012-03-13 00:33:15 +08:00
|
|
|
|
dump_fcontents(fid);
|
|
|
|
|
end_obj(h5tools_dump_header_format->fileend,h5tools_dump_header_format->fileblockend);
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2012-03-13 00:33:15 +08:00
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (display_bb)
|
|
|
|
|
dump_fcpl(fid);
|
2012-02-18 05:41:58 +08:00
|
|
|
|
}
|
2003-07-30 05:24:21 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if(display_all) {
|
|
|
|
|
if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) {
|
|
|
|
|
error_msg("unable to open root group\n");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (!doxml)
|
|
|
|
|
dump_indent += COL;
|
|
|
|
|
dump_function_table->dump_group_function(gid, "/" );
|
|
|
|
|
if (!doxml)
|
|
|
|
|
dump_indent -= COL;
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2012-03-13 00:33:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(H5Gclose(gid) < 0) {
|
|
|
|
|
error_msg("unable to close root group\n");
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
}
|
2005-08-26 04:16:40 +08:00
|
|
|
|
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* Note: this option is not supported for XML */
|
|
|
|
|
if(doxml) {
|
|
|
|
|
error_msg("internal error (file %s:line %d)\n", __FILE__, __LINE__);
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
goto done;
|
|
|
|
|
} /* end if */
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < argc; i++) {
|
|
|
|
|
if(hand[i].func) {
|
|
|
|
|
hand[i].func(fid, hand[i].obj, hand[i].subset_info, 1, NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2005-08-26 04:16:40 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if (!doxml) {
|
|
|
|
|
end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend);
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTVALSTREAM(rawoutstream, "\n");
|
2012-03-13 00:33:15 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
2013-01-23 04:43:12 +08:00
|
|
|
|
PRINTSTREAM(rawoutstream, "</%sHDF5-File>\n", xmlnsprefix);
|
2007-09-13 23:44:56 +08:00
|
|
|
|
}
|
2012-03-13 00:33:15 +08:00
|
|
|
|
/* Free tables for objects */
|
|
|
|
|
table_list_free();
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if(fid >=0)
|
|
|
|
|
if (H5Fclose(fid) < 0)
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if(prefix)
|
|
|
|
|
HDfree(prefix);
|
|
|
|
|
if(fname)
|
|
|
|
|
HDfree(fname);
|
|
|
|
|
} /* end while */
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if(hand)
|
|
|
|
|
free_handler(hand, argc);
|
|
|
|
|
|
|
|
|
|
/* To Do: clean up XML table */
|
|
|
|
|
|
|
|
|
|
leave(h5tools_getstatus());
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
done:
|
|
|
|
|
/* Free tables for objects */
|
|
|
|
|
table_list_free();
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
if(fid >=0)
|
|
|
|
|
if (H5Fclose(fid) < 0)
|
|
|
|
|
h5tools_setstatus(EXIT_FAILURE);
|
|
|
|
|
|
|
|
|
|
if(prefix)
|
|
|
|
|
HDfree(prefix);
|
|
|
|
|
if(fname)
|
|
|
|
|
HDfree(fname);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-03-13 00:33:15 +08:00
|
|
|
|
if(hand)
|
|
|
|
|
free_handler(hand, argc);
|
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
/* To Do: clean up XML table */
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
H5Eset_auto2(H5E_DEFAULT, func, edata);
|
2001-02-23 05:53:30 +08:00
|
|
|
|
|
2012-02-18 05:41:58 +08:00
|
|
|
|
leave(h5tools_getstatus());
|
2001-02-23 05:53:30 +08:00
|
|
|
|
}
|
2004-06-08 00:40:25 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2007-03-13 00:36:34 +08:00
|
|
|
|
* Function: h5_fileaccess
|
2004-06-08 00:40:25 +08:00
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
|
* Purpose: Returns a file access template which is the default template
|
|
|
|
|
* but with a file driver set according to the constant or
|
|
|
|
|
* environment variable HDF5_DRIVER
|
2004-06-08 00:40:25 +08:00
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
|
* Return: Success: A file access property list
|
2004-06-08 00:40:25 +08:00
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
|
* Failure: -1
|
2004-06-08 00:40:25 +08:00
|
|
|
|
*
|
2007-03-13 00:36:34 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2004-06-08 00:40:25 +08:00
|
|
|
|
* Thursday, November 19, 1998
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
hid_t
|
2004-06-08 00:40:25 +08:00
|
|
|
|
h5_fileaccess(void)
|
|
|
|
|
{
|
2004-10-07 00:11:18 +08:00
|
|
|
|
static const char *multi_letters = "msbrglo";
|
2007-03-13 00:36:34 +08:00
|
|
|
|
const char *val = NULL;
|
|
|
|
|
const char *name;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
char s[1024];
|
|
|
|
|
hid_t fapl = -1;
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2004-06-08 00:40:25 +08:00
|
|
|
|
/* First use the environment variable, then the constant */
|
|
|
|
|
val = HDgetenv("HDF5_DRIVER");
|
|
|
|
|
#ifdef HDF5_DRIVER
|
|
|
|
|
if (!val) val = HDF5_DRIVER;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
|
|
|
|
|
if (!val || !*val) return fapl; /*use default*/
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2004-06-08 00:40:25 +08:00
|
|
|
|
HDstrncpy(s, val, sizeof s);
|
|
|
|
|
s[sizeof(s)-1] = '\0';
|
|
|
|
|
if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl;
|
|
|
|
|
|
|
|
|
|
if (!HDstrcmp(name, "sec2")) {
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* Unix read() and write() system calls */
|
|
|
|
|
if (H5Pset_fapl_sec2(fapl)<0) return -1;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "stdio")) {
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* Standard C fread() and fwrite() system calls */
|
|
|
|
|
if (H5Pset_fapl_stdio(fapl)<0) return -1;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "core")) {
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* In-core temporary file with 1MB increment */
|
|
|
|
|
if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "split")) {
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* Split meta data and raw data each using default driver */
|
2011-05-04 01:56:23 +08:00
|
|
|
|
if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "multi")) {
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* Multi-file driver, general case of the split driver */
|
2011-05-04 01:56:23 +08:00
|
|
|
|
H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
|
|
|
|
|
hid_t memb_fapl[H5FD_MEM_NTYPES];
|
|
|
|
|
const char *memb_name[H5FD_MEM_NTYPES];
|
|
|
|
|
char sv[H5FD_MEM_NTYPES][1024];
|
|
|
|
|
haddr_t memb_addr[H5FD_MEM_NTYPES];
|
|
|
|
|
H5FD_mem_t mt;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
|
|
|
|
|
HDmemset(memb_map, 0, sizeof memb_map);
|
|
|
|
|
HDmemset(memb_fapl, 0, sizeof memb_fapl);
|
|
|
|
|
HDmemset(memb_name, 0, sizeof memb_name);
|
|
|
|
|
HDmemset(memb_addr, 0, sizeof memb_addr);
|
|
|
|
|
|
2012-02-24 03:08:09 +08:00
|
|
|
|
HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
|
2007-09-13 23:44:56 +08:00
|
|
|
|
for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
|
|
|
|
|
memb_fapl[mt] = H5P_DEFAULT;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
memb_map[mt] = mt;
|
2007-09-13 23:44:56 +08:00
|
|
|
|
sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
|
|
|
|
|
memb_name[mt] = sv[mt];
|
|
|
|
|
memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
|
|
|
|
|
}
|
2007-03-13 00:36:34 +08:00
|
|
|
|
|
2011-05-04 01:56:23 +08:00
|
|
|
|
if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0)
|
2007-09-13 23:44:56 +08:00
|
|
|
|
return -1;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "family")) {
|
2004-06-08 00:40:25 +08:00
|
|
|
|
hsize_t fam_size = 100*1024*1024; /*100 MB*/
|
|
|
|
|
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* Family of files, each 1MB and using the default driver */
|
|
|
|
|
if ((val=HDstrtok(NULL, " \t\n\r")))
|
|
|
|
|
fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024);
|
|
|
|
|
if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0)
|
2011-05-04 01:56:23 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "log")) {
|
2004-06-08 00:40:25 +08:00
|
|
|
|
long log_flags = H5FD_LOG_LOC_IO;
|
|
|
|
|
|
|
|
|
|
/* Log file access */
|
|
|
|
|
if ((val = HDstrtok(NULL, " \t\n\r")))
|
|
|
|
|
log_flags = HDstrtol(val, NULL, 0);
|
|
|
|
|
|
|
|
|
|
if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0)
|
2007-09-13 23:44:56 +08:00
|
|
|
|
return -1;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else if (!HDstrcmp(name, "direct")) {
|
2006-10-11 04:07:16 +08:00
|
|
|
|
/* Substitute Direct I/O driver with sec2 driver temporarily because
|
2008-09-16 23:52:51 +08:00
|
|
|
|
* some output has sec2 driver as the standard. */
|
2007-09-13 23:44:56 +08:00
|
|
|
|
if (H5Pset_fapl_sec2(fapl)<0) return -1;
|
2011-05-04 01:56:23 +08:00
|
|
|
|
}
|
|
|
|
|
else {
|
2007-09-13 23:44:56 +08:00
|
|
|
|
/* Unknown driver */
|
|
|
|
|
return -1;
|
2004-06-08 00:40:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return fapl;
|
|
|
|
|
}
|
2005-08-26 04:16:40 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: init_prefix
|
|
|
|
|
*
|
|
|
|
|
* Purpose: allocate and initialize prefix
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
init_prefix(char **prfx, size_t prfx_len)
|
|
|
|
|
{
|
2006-01-24 04:46:34 +08:00
|
|
|
|
HDassert(prfx_len > 0);
|
2010-08-20 03:55:48 +08:00
|
|
|
|
*prfx = (char *)HDcalloc(prfx_len, 1);
|
2005-08-26 04:16:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2006-01-24 04:46:34 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: add_prefix
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Add object to prefix
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2012-02-18 05:41:58 +08:00
|
|
|
|
void
|
2006-01-24 04:46:34 +08:00
|
|
|
|
add_prefix(char **prfx, size_t *prfx_len, const char *name)
|
|
|
|
|
{
|
|
|
|
|
size_t new_len = HDstrlen(*prfx) + HDstrlen(name) + 2;
|
|
|
|
|
|
|
|
|
|
/* Check if we need more space */
|
|
|
|
|
if(*prfx_len <= new_len) {
|
|
|
|
|
*prfx_len = new_len + 1;
|
2010-08-20 03:55:48 +08:00
|
|
|
|
*prfx = (char *)HDrealloc(*prfx, *prfx_len);
|
2006-01-24 04:46:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Append object name to prefix */
|
|
|
|
|
HDstrcat(HDstrcat(*prfx, "/"), name);
|
|
|
|
|
} /* end add_prefix */
|
|
|
|
|
|