summaryrefslogtreecommitdiffstats
path: root/tools/h5tools.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2000-11-02 04:59:51 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2000-11-02 04:59:51 (GMT)
commit48b4b454816677b3b79d03bb4d4dc7b1eef90e30 (patch)
tree5335b3f7ab3b8c2d8beb914cc4cd7030c6065696 /tools/h5tools.c
parent180a47a037320fc8fcf48cf3114e1f548d019659 (diff)
downloadhdf5-48b4b454816677b3b79d03bb4d4dc7b1eef90e30.zip
hdf5-48b4b454816677b3b79d03bb4d4dc7b1eef90e30.tar.gz
hdf5-48b4b454816677b3b79d03bb4d4dc7b1eef90e30.tar.bz2
[svn-r2790] Purpose:
new feature Description: h5tools.c: Created h5tools_init() and h5tools_close() for the initialization of the h5tools library and closing of it. With this, the rawdatastream and other internal structures can be initialized properly. h5tools.h: added prototypes for h5tools_init and h5tools_close. h5dump.c: h5ls.c: Added the calls for h5tools_init() and h5tools_close(). Platforms tested: IRIX64 -64 parallel and Linux
Diffstat (limited to 'tools/h5tools.c')
-rw-r--r--tools/h5tools.c61
1 files changed, 57 insertions, 4 deletions
diff --git a/tools/h5tools.c b/tools/h5tools.c
index 52851ca..78a8258 100644
--- a/tools/h5tools.c
+++ b/tools/h5tools.c
@@ -26,6 +26,8 @@ int compound_data;
int nCols = 80;
FILE *rawdatastream; /* should initialize to stdout but gcc moans about it */
+static int h5tools_init_g = 0; /* if h5tools lib has been initialized */
+
int print_data(hid_t oid, hid_t _p_type, int obj_data);
/*
@@ -107,6 +109,61 @@ extern char *get_objectname(table_t*, int);
static int h5dump_vlen_dset(FILE *, const h5dump_t *, hid_t, hid_t, int);
/*-------------------------------------------------------------------------
+ * Function: h5tools_init
+ *
+ * Purpose: Initialize the H5 Tools library.
+ * 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
+ *
+ * Modifications:
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_init(void)
+{
+ if (!h5tools_init_g){
+ if (!rawdatastream)
+ rawdatastream = stdout;
+ h5tools_init_g++;
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_close
+ *
+ * Purpose: Close the H5 Tools library by closing or releasing 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
+ *
+ * Modifications:
+ *-------------------------------------------------------------------------
+ */
+void
+h5tools_close(void)
+{
+ if (h5tools_init_g){
+ if (rawdatastream && rawdatastream != stdout){
+ if (fclose(rawdatastream))
+ perror("closing rawdatastream");
+ else
+ rawdatastream = NULL;
+ }
+ h5tools_init_g = 0;
+ }
+}
+
+/*-------------------------------------------------------------------------
* Function: h5dump_str_close
*
* Purpose: Closes a string by releasing it's memory and setting the size
@@ -1814,10 +1871,6 @@ h5dump_dset(FILE *stream, const h5dump_t *info, hid_t dset, hid_t _p_type,
f_space = H5Dget_space(dset);
/* Print the data */
- /* a kludge because gcc does not accept the initialization with sdtout */
- if (!rawdatastream)
- rawdatastream = stdout;
-
if (H5Sis_simple(f_space) > 0) {
/* Probably a compound datatype or something... */
if (H5Tget_class(p_type) == H5T_VLEN) {