summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--c++/src/H5CommonFG.cpp24
-rw-r--r--fortran/src/H5Gf.c132
-rw-r--r--src/H5Gdeprec.c123
-rw-r--r--src/H5Gloc.c212
-rw-r--r--src/H5Gprivate.h4
-rw-r--r--src/H5Gpublic.h6
-rw-r--r--src/H5O.c92
-rw-r--r--src/H5Opublic.h4
-rw-r--r--test/dsets.c4
-rw-r--r--test/links.c42
-rw-r--r--test/stab.c4
-rw-r--r--test/trefer.c8
-rw-r--r--test/tunicode.c8
-rw-r--r--tools/h5dump/h5dump.c14
-rw-r--r--tools/h5dump/h5dumpgentest.c88
-rw-r--r--tools/h5ls/h5ls.c44
16 files changed, 502 insertions, 307 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 5904f67..251131d 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -455,10 +455,10 @@ H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const
//--------------------------------------------------------------------------
void CommonFG::setComment( const char* name, const char* comment ) const
{
- herr_t ret_value = H5Gset_comment( getLocId(), name, comment );
+ herr_t ret_value = H5Oset_comment( getLocId(), name, comment, H5P_DEFAULT );
if( ret_value < 0 )
{
- throwException("setComment", "H5Gset_comment failed");
+ throwException("setComment", "H5Oset_comment failed");
}
}
@@ -483,10 +483,10 @@ void CommonFG::setComment( const H5std_string& name, const H5std_string& comment
//--------------------------------------------------------------------------
void CommonFG::removeComment(const char* name) const
{
- herr_t ret_value = H5Gset_comment(getLocId(), name, NULL);
+ herr_t ret_value = H5Oset_comment(getLocId(), name, NULL, H5P_DEFAULT);
if( ret_value < 0 )
{
- throwException("removeComment", "H5Gset_comment failed");
+ throwException("removeComment", "H5Oset_comment failed");
}
}
@@ -517,23 +517,23 @@ H5std_string CommonFG::getComment (const H5std_string& name) const
// temporary C-string for the object's comment
char* comment_C = new char[bufsize+1];
- herr_t ret_value = H5Gget_comment (loc_id, name.c_str(), bufsize, comment_C);
+ herr_t ret_value = H5Oget_comment(loc_id, name.c_str(), comment_C, bufsize, H5P_DEFAULT);
// if the actual length of the comment is longer than the anticipated
- // value, then call H5Gget_comment again with the correct value
+ // value, then call H5Oget_comment again with the correct value
if (ret_value > bufsize)
{
bufsize = ret_value;
delete []comment_C;
comment_C = new char[bufsize+1];
- ret_value = H5Gget_comment (loc_id, name.c_str(), bufsize, comment_C);
+ ret_value = H5Oget_comment(loc_id, name.c_str(), comment_C, bufsize, H5P_DEFAULT);
}
- // if H5Gget_comment returns SUCCEED, return the string comment,
+ // if H5Oget_comment returns SUCCEED, return the string comment,
// otherwise, throw an exception
if( ret_value < 0 )
{
- throwException("getComment", "H5Gget_comment failed");
+ throwException("getComment", "H5Oget_comment failed");
}
H5std_string comment = H5std_string(comment_C);
delete []comment_C;
@@ -555,12 +555,12 @@ H5std_string CommonFG::getComment( const char* name, size_t bufsize ) const
// temporary C-string for the object's comment
char* comment_C = new char[bufsize+1];
- herr_t ret_value = H5Gget_comment( getLocId(), name, bufsize, comment_C );
+ herr_t ret_value = H5Oget_comment( getLocId(), name, comment_C, bufsize, H5P_DEFAULT );
- // if H5Gget_comment returns SUCCEED, return the string comment
+ // if H5Oget_comment returns SUCCEED, return the string comment
if( ret_value < 0 )
{
- throwException("getComment", "H5Gget_comment failed");
+ throwException("getComment", "H5Oget_comment failed");
}
H5std_string comment = H5std_string(comment_C);
delete []comment_C;
diff --git a/fortran/src/H5Gf.c b/fortran/src/H5Gf.c
index 3b25a79..e405944 100644
--- a/fortran/src/H5Gf.c
+++ b/fortran/src/H5Gf.c
@@ -580,40 +580,35 @@ DONE:
*---------------------------------------------------------------------------*/
int_f
-nh5gset_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, _fcd comment, int_f*commentlen)
+nh5gset_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, _fcd comment,
+ int_f*commentlen)
{
- int ret_value = -1;
- hid_t c_loc_id;
- char *c_name, *c_comment;
- size_t c_namelen, c_commentlen;
- herr_t c_ret_value;
- /*
- * Convert Fortran name to C name
- */
- c_namelen = *namelen;
- c_commentlen =*commentlen;
- c_name = (char *)HD5f2cstring(name, c_namelen);
- if(c_name == NULL) return ret_value;
-
- c_comment = (char *)HD5f2cstring(comment, c_commentlen);
- if(c_comment == NULL) { HDfree (c_name);
- return ret_value;
- }
- /*
- * Call H5Gset_comment function
- */
- c_loc_id = (hid_t)*loc_id;
- c_ret_value = H5Gset_comment(c_loc_id, c_name, c_comment);
- if(c_ret_value < 0) goto DONE;
- ret_value = 0;
+ char *c_name = NULL, *c_comment = NULL;
+ int ret_value = -1;
+
+ /*
+ * Convert Fortran name to C name
+ */
+ if(NULL == (c_name = (char *)HD5f2cstring(name, c_namelen)))
+ goto DONE;
+ if(NULL == (c_comment = (char *)HD5f2cstring(comment, (size_t)*commentlen)))
+ goto DONE;
+
+ /*
+ * Call H5Gset_comment function
+ */
+ if(H5Oset_comment((hid_t)*loc_id, c_name, c_comment, H5P_DEFAULT) < 0)
+ goto DONE;
+ ret_value = 0;
DONE:
- HDfree(c_name);
- HDfree(c_comment);
- return ret_value ;
+ if(c_name)
+ HDfree(c_name);
+ if(c_comment)
+ HDfree(c_comment);
+ return ret_value;
}
-
/*----------------------------------------------------------------------------
* Name: h5gget_comment_c
* Purpose: Call H5Gget_comment to retrieve comments for the specified object
@@ -629,48 +624,45 @@ DONE:
*---------------------------------------------------------------------------*/
int_f
-nh5gget_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *bufsize, _fcd comment)
+nh5gget_comment_c(hid_t_f *loc_id, _fcd name, int_f *namelen, size_t_f *bufsize,
+ _fcd comment)
{
- int ret_value = -1;
- hid_t c_loc_id;
- char *c_name;
- size_t c_namelen;
- char *c_comment = NULL;
- size_t c_bufsize;
- herr_t c_ret_value;
-
- /*
- * Convert Fortran name to C name
- */
- c_namelen = *namelen;
- c_name = (char *)HD5f2cstring(name, c_namelen);
- if(c_name == NULL) return ret_value;
-
- /*
- * Allocate buffer to hold the comment
- */
- c_bufsize = (size_t)*bufsize;
- if(c_bufsize) c_comment = (char *)malloc(c_bufsize + 1);
- if(c_comment == NULL) {
- HDfree(c_name);
- return ret_value;
- }
-
- /*
- * Call H5Gget_comment function
- */
- c_loc_id = *loc_id;
- c_ret_value = H5Gget_comment(c_loc_id, c_name, c_bufsize, c_comment);
- if(c_ret_value < 0) goto DONE;
-
- /*
- * Convert C name to FORTRAN and place it in the given buffer
- */
- HD5packFstring(c_comment, _fcdtocp(comment), (size_t)*bufsize);
- ret_value = 0;
+ char *c_name = NULL, *c_comment = NULL;
+ size_t c_bufsize;
+ int ret_value = -1;
+
+ /*
+ * Convert Fortran name to C name
+ */
+ if(NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
+ goto DONE;
+
+ /*
+ * Allocate buffer to hold the comment
+ */
+ c_bufsize = (size_t)*bufsize;
+ if(c_bufsize) {
+ if(NULL == (c_comment = (char *)HDmalloc(c_bufsize + 1)))
+ goto DONE;
+ } /* end if */
+
+ /*
+ * Call H5Gget_comment function
+ */
+ if(H5Oget_comment((hid_t)*loc_id, c_name, c_comment, c_bufsize, H5P_DEFAULT) < 0)
+ goto DONE;
+
+ /*
+ * Convert C name to FORTRAN and place it in the given buffer
+ */
+ HD5packFstring(c_comment, _fcdtocp(comment), c_bufsize);
+ ret_value = 0;
DONE:
- HDfree(c_name);
- HDfree(c_comment);
- return ret_value ;
+ if(c_name)
+ HDfree(c_name);
+ if(c_comment)
+ HDfree(c_comment);
+ return ret_value;
}
+
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index 2662778..2ce8aa3 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -81,10 +81,6 @@ static herr_t H5G_link_hard(hid_t cur_loc_id, const char *cur_name,
static herr_t H5G_move(hid_t src_loc_id, const char *src_name,
hid_t dst_loc_id, const char *dst_name);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
-static herr_t H5G_set_comment(H5G_loc_t *loc, const char *name,
- const char *buf, hid_t dxpl_id);
-static int H5G_get_comment(H5G_loc_t *loc, const char *name,
- size_t bufsize, char *buf, hid_t dxpl_id);
static herr_t H5G_get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
H5G_own_loc_t *own_loc/*out*/);
@@ -637,6 +633,7 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gget_objname_by_idx() */
+#ifndef H5_NO_DEPRECATED_SYMBOLS
/*-------------------------------------------------------------------------
* Function: H5Gset_comment
@@ -646,7 +643,7 @@ done:
* one comment at a time. Passing NULL for the COMMENT argument
* will remove the comment property from the object.
*
- * Note: Deprecated in favor of using attributes on group
+ * Note: Deprecated in favor of using attributes on object
*
* Return: Non-negative on success/Negative on failure
*
@@ -669,7 +666,7 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
- if(H5G_set_comment(&loc, name, comment, H5AC_dxpl_id) < 0)
+ if(H5G_loc_set_comment(&loc, name, comment, H5P_DEFAULT, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value")
done:
@@ -716,123 +713,13 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
if(bufsize > 0 && !buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified")
- if((ret_value = H5G_get_comment(&loc, name, bufsize, buf, H5AC_ind_dxpl_id)) < 0)
+ if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gget_comment() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5G_set_comment
- *
- * Purpose: (Re)sets the comment for an object.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Robb Matzke
- * Monday, July 20, 1998
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5G_set_comment(H5G_loc_t *loc, const char *name, const char *buf, hid_t dxpl_id)
-{
- H5G_loc_t obj_loc; /* Object's location */
- H5G_name_t path;
- H5O_loc_t oloc;
- hbool_t loc_valid = FALSE;
- H5O_name_t comment;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5G_set_comment)
-
- /* Get the symbol table entry for the object */
- obj_loc.path = &path;
- obj_loc.oloc = &oloc;
- H5G_loc_reset(&obj_loc);
- if(H5G_loc_find(loc, name, &obj_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
- loc_valid = TRUE;
-
- /* Remove the previous comment message if any */
- if(H5O_msg_remove(obj_loc.oloc, H5O_NAME_ID, 0, TRUE, dxpl_id) < 0)
- H5E_clear_stack(NULL);
-
- /* Add the new message */
- if(buf && *buf) {
- /* Casting away const OK -QAK */
- comment.s = (char *)buf;
- if(H5O_msg_create(obj_loc.oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message")
- } /* end if */
-
-done:
- /* Release obj_loc */
- if(loc_valid && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_set_comment() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5G_get_comment
- *
- * Purpose: Get the comment value for an object.
- *
- * Return: Success: Number of bytes in the comment including the
- * null terminator. Zero if the object has no
- * comment.
- *
- * Failure: Negative
- *
- * Programmer: Robb Matzke
- * Monday, July 20, 1998
- *
- *-------------------------------------------------------------------------
- */
-static int
-H5G_get_comment(H5G_loc_t *loc, const char *name, size_t bufsize, char *buf, hid_t dxpl_id)
-{
- H5O_name_t comment;
- H5G_loc_t obj_loc; /* Object's location */
- H5G_name_t path;
- H5O_loc_t oloc;
- hbool_t loc_valid = FALSE;
- int ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT(H5G_get_comment)
-
- /* Get the symbol table entry for the object */
- obj_loc.path = &path;
- obj_loc.oloc = &oloc;
- H5G_loc_reset(&obj_loc);
- if(H5G_loc_find(loc, name, &obj_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
- loc_valid = TRUE;
-
- /* Get the message */
- comment.s = NULL;
- if(NULL == H5O_msg_read(obj_loc.oloc, H5O_NAME_ID, &comment, dxpl_id)) {
- if(buf && bufsize > 0)
- buf[0] = '\0';
- ret_value = 0;
- } else {
- if(buf && bufsize)
- HDstrncpy(buf, comment.s, bufsize);
- ret_value = (int)HDstrlen(comment.s);
- H5O_msg_reset(H5O_NAME_ID, &comment);
- } /* end else */
-
-done:
- /* Release obj_loc */
- if(loc_valid && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_get_comment() */
+#endif /* H5_NO_DEPRECATED_SYMBOLS */
/*-------------------------------------------------------------------------
diff --git a/src/H5Gloc.c b/src/H5Gloc.c
index 20c8a08..fc02539 100644
--- a/src/H5Gloc.c
+++ b/src/H5Gloc.c
@@ -79,6 +79,26 @@ typedef struct {
H5O_info_t *oinfo; /* Object information to retrieve */
} H5G_loc_info_t;
+/* User data for setting an object's comment in a group */
+typedef struct {
+ /* downward */
+ hid_t dxpl_id; /* DXPL to use for operation */
+ const char *comment; /* Object comment buffer */
+
+ /* upward */
+} H5G_loc_sc_t;
+
+/* User data for getting an object's comment in a group */
+typedef struct {
+ /* downward */
+ hid_t dxpl_id; /* DXPL to use for operation */
+ char *comment; /* Object comment buffer */
+ size_t bufsize; /* Size of object comment buffer */
+
+ /* upward */
+ ssize_t comment_size; /* Actual size of object comment */
+} H5G_loc_gc_t;
+
/********************/
/* Local Prototypes */
@@ -87,10 +107,16 @@ typedef struct {
/* Group traversal callbacks */
static herr_t H5G_loc_find_cb(H5G_loc_t *grp_loc, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata,
- H5G_own_loc_t *own_loc/*out*/);
+ H5G_own_loc_t *own_loc);
static herr_t H5G_loc_find_by_idx_cb(H5G_loc_t *grp_loc, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata,
- H5G_own_loc_t *own_loc/*out*/);
+ H5G_own_loc_t *own_loc);
+static herr_t H5G_loc_set_comment_cb(H5G_loc_t *grp_loc, const char *name,
+ const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata,
+ H5G_own_loc_t *own_loc);
+static herr_t H5G_loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name,
+ const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata,
+ H5G_own_loc_t *own_loc);
/*********************/
@@ -682,3 +708,185 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_loc_info() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_loc_set_comment_cb
+ *
+ * Purpose: Callback for (re)setting object comment for an object in a group
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 30, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5G_loc_set_comment_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, const H5O_link_t UNUSED *lnk,
+ H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/)
+{
+ H5G_loc_sc_t *udata = (H5G_loc_sc_t *)_udata; /* User data passed in */
+ H5O_name_t comment; /* Object header "comment" message */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5G_loc_set_comment_cb)
+
+ /* Check if the name in this group resolved to a valid link */
+ if(obj_loc == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist")
+
+ /* Remove the previous comment message if any */
+ if(H5O_msg_remove(obj_loc->oloc, H5O_NAME_ID, 0, TRUE, udata->dxpl_id) < 0)
+ H5E_clear_stack(NULL);
+
+ /* Add the new message */
+ if(udata->comment && *udata->comment) {
+ /* Casting away const OK -QAK */
+ comment.s = (char *)udata->comment;
+ if(H5O_msg_create(obj_loc->oloc, H5O_NAME_ID, 0, H5O_UPDATE_TIME, &comment, udata->dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message")
+ } /* end if */
+
+done:
+ /* Indicate that this callback didn't take ownership of the group *
+ * location for the object */
+ *own_loc = H5G_OWN_NONE;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_loc_set_comment_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_loc_set_comment
+ *
+ * Purpose: (Re)set the information for an object from a group location
+ * and path to that object
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 30, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_loc_set_comment(H5G_loc_t *loc, const char *name, const char *comment,
+ hid_t lapl_id, hid_t dxpl_id)
+{
+ H5G_loc_sc_t udata; /* User data for traversal callback */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_loc_set_comment, FAIL)
+
+ /* Check args. */
+ HDassert(loc);
+ HDassert(name && *name);
+
+ /* Set up user data for locating object */
+ udata.dxpl_id = dxpl_id;
+ udata.comment = comment;
+
+ /* Traverse group hierarchy to locate object */
+ if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G_loc_set_comment_cb, &udata, lapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_loc_set_comment() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_loc_get_comment_cb
+ *
+ * Purpose: Callback for retrieving object comment for an object in a group
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 30, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5G_loc_get_comment_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, const H5O_link_t UNUSED *lnk,
+ H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/)
+{
+ H5G_loc_gc_t *udata = (H5G_loc_gc_t *)_udata; /* User data passed in */
+ H5O_name_t comment; /* Object header "comment" message */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5G_loc_get_comment_cb)
+
+ /* Check if the name in this group resolved to a valid link */
+ if(obj_loc == NULL)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist")
+
+ /* Query object comment */
+ comment.s = NULL;
+ if(NULL == H5O_msg_read(obj_loc->oloc, H5O_NAME_ID, &comment, udata->dxpl_id)) {
+ if(udata->comment && udata->bufsize > 0)
+ udata->comment[0] = '\0';
+ udata->comment_size = 0;
+ } else {
+ if(udata->comment && udata->bufsize)
+ HDstrncpy(udata->comment, comment.s, udata->bufsize);
+ udata->comment_size = HDstrlen(comment.s);
+ H5O_msg_reset(H5O_NAME_ID, &comment);
+ } /* end else */
+
+done:
+ /* Indicate that this callback didn't take ownership of the group *
+ * location for the object */
+ *own_loc = H5G_OWN_NONE;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_loc_get_comment_cb() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_loc_get_comment
+ *
+ * Purpose: Retrieve the information for an object from a group location
+ * and path to that object
+ *
+ * Return: Success: Number of bytes in the comment including the
+ * null terminator. Zero if the object has no
+ * comment.
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, August 30, 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5G_loc_get_comment(H5G_loc_t *loc, const char *name, char *comment/*out*/,
+ size_t bufsize, hid_t lapl_id, hid_t dxpl_id)
+{
+ H5G_loc_gc_t udata; /* User data for traversal callback */
+ ssize_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_loc_get_comment, FAIL)
+
+ /* Check args. */
+ HDassert(loc);
+ HDassert(name && *name);
+
+ /* Set up user data for locating object */
+ udata.dxpl_id = dxpl_id;
+ udata.comment = comment;
+ udata.bufsize = bufsize;
+ udata.comment_size = (-1);
+
+ /* Traverse group hierarchy to locate object */
+ if(H5G_traverse(loc, name, H5G_TARGET_NORMAL, H5G_loc_get_comment_cb, &udata, lapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't find object")
+
+ /* Set the return value */
+ ret_value = udata.comment_size;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_loc_get_comment() */
+
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 82b667b..14e10ff 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -200,6 +200,10 @@ H5_DLL herr_t H5G_loc_find_by_idx(H5G_loc_t *loc, const char *group_name,
H5_DLL herr_t H5G_loc_info(H5G_loc_t *loc, const char *name,
hbool_t want_ih_info, H5O_info_t *oinfo/*out*/, hid_t lapl_id,
hid_t dxpl_id);
+H5_DLL herr_t H5G_loc_set_comment(H5G_loc_t *loc, const char *name,
+ const char *comment, hid_t lapl_id, hid_t dxpl_id);
+H5_DLL ssize_t H5G_loc_get_comment(H5G_loc_t *loc, const char *name,
+ char *comment/*out*/, size_t bufsize, hid_t lapl_id, hid_t dxpl_id);
H5_DLL herr_t H5G_loc_reset(H5G_loc_t *loc);
H5_DLL herr_t H5G_loc_free(H5G_loc_t *loc);
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index e0133c5..26baf8b 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -139,9 +139,6 @@ H5_DLL herr_t H5Gclose(hid_t group_id);
*/
H5_DLL ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char* name,
size_t size);
-H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment);
-H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
- char *buf);
H5_DLL herr_t H5Giterate(hid_t loc_id, const char *name, int *idx,
H5G_iterate_t op, void *op_data);
H5_DLL H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx);
@@ -170,6 +167,9 @@ H5_DLL herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
H5_DLL herr_t H5Gunlink(hid_t loc_id, const char *name);
H5_DLL herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size,
char *buf/*out*/);
+H5_DLL herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment);
+H5_DLL int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize,
+ char *buf);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
diff --git a/src/H5O.c b/src/H5O.c
index c8c9d69..aa6b161 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -488,6 +488,7 @@ H5Oget_info(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id)
/* Retrieve the object's information */
if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Oget_info() */
@@ -563,6 +564,97 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Oset_comment
+ *
+ * Purpose: Gives the specified object a comment. The COMMENT string
+ * should be a null terminated string. An object can have only
+ * one comment at a time. Passing NULL for the COMMENT argument
+ * will remove the comment property from the object.
+ *
+ * Note: Deprecated in favor of using attributes on objects
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * August 30 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Oset_comment(hid_t loc_id, const char *name, const char *comment,
+ hid_t lapl_id)
+{
+ H5G_loc_t loc; /* Location of group */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(H5Oset_comment, FAIL)
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(H5P_DEFAULT == lapl_id)
+ lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+
+ /* (Re)set the object's comment */
+ if(H5G_loc_set_comment(&loc, name, comment, lapl_id, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Oset_comment() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Oget_comment
+ *
+ * Purpose: Retrieve comment for an object.
+ *
+ * Return: Success: Number of bytes in the comment including the
+ * null terminator. Zero if the object has no
+ * comment.
+ *
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * August 30 2007
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5Oget_comment(hid_t loc_id, const char *name, char *comment, size_t bufsize,
+ hid_t lapl_id)
+{
+ H5G_loc_t loc; /* Location of group */
+ ssize_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Oget_comment, FAIL)
+
+ /* Check args */
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if(!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ if(H5P_DEFAULT == lapl_id)
+ lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+
+ /* Retrieve the object's comment */
+ if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Oget_comment() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Oclose
*
* Purpose: Close an open file object.
diff --git a/src/H5Opublic.h b/src/H5Opublic.h
index b10a4e4..17fe139 100644
--- a/src/H5Opublic.h
+++ b/src/H5Opublic.h
@@ -156,6 +156,10 @@ H5_DLL herr_t H5Oincr_refcount(hid_t object_id);
H5_DLL herr_t H5Odecr_refcount(hid_t object_id);
H5_DLL herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id);
+H5_DLL herr_t H5Oset_comment(hid_t loc_id, const char *name,
+ const char *comment, hid_t lapl_id);
+H5_DLL ssize_t H5Oget_comment(hid_t loc_id, const char *name, char *comment,
+ size_t bufsize, hid_t lapl_id);
H5_DLL herr_t H5Oclose(hid_t object_id);
#ifdef __cplusplus
diff --git a/test/dsets.c b/test/dsets.c
index d1c6e17..6469a5e 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -211,7 +211,7 @@ test_create(hid_t file)
if (H5Dclose(dataset) < 0) goto error;
/* Add a comment to the dataset */
- status = H5Gset_comment(file, DSET_DEFAULT_NAME, "This is a dataset");
+ status = H5Oset_comment(file, DSET_DEFAULT_NAME, "This is a dataset", H5P_DEFAULT);
if (status<0) goto error;
/*
@@ -6273,7 +6273,7 @@ main(void)
/* Cause the library to emit initial messages */
if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
goto error;
- if(H5Gset_comment(grp, ".", "Causes diagnostic messages to be emitted") < 0)
+ if(H5Oset_comment(grp, ".", "Causes diagnostic messages to be emitted", H5P_DEFAULT) < 0)
goto error;
if(H5Gclose(grp) < 0)
goto error;
diff --git a/test/links.c b/test/links.c
index 8e87ecc..fe3ea79 100644
--- a/test/links.c
+++ b/test/links.c
@@ -1493,6 +1493,11 @@ test_compat(hid_t fapl, hbool_t new_format)
if((group1_id = H5Gcreate2(file_id, "group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
if((group2_id = H5Gcreate2(file_id, "group2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Test H5Gset and get comment */
+ if(H5Gset_comment(file_id, "group1", "comment") < 0) FAIL_STACK_ERROR
+ if(H5Gget_comment(file_id, "group1", sizeof(linkval), linkval) < 0) FAIL_STACK_ERROR
+ if(HDstrcmp(linkval, "comment")) TEST_ERROR
+
/* Create links using H5Glink and H5Glink2 */
if(H5Glink(file_id, H5G_LINK_HARD, "group2", "group1/link_to_group2") < 0) FAIL_STACK_ERROR
if(H5Glink2(file_id, "group1", H5G_LINK_HARD, group2_id, "link_to_group1") < 0) FAIL_STACK_ERROR
@@ -3400,42 +3405,43 @@ external_link_closing(hid_t fapl, hbool_t new_format)
"elink/elink/elink/group1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
/* Open file 4 so we can do some fancy things */
- if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR
+ if((fid4 = H5Fopen(filename4, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR
if(H5Lmove(fid1, "elink/elink/elink/type1", fid4,
- "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ "type1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(H5Lmove(fid4, "dataset1", fid1,
- "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ "elink/elink/elink/dataset1_moved", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Close file 4 again */
- if(H5Fclose(fid4) < 0) TEST_ERROR
+ if(H5Fclose(fid4) < 0) FAIL_STACK_ERROR
/* Test copy (as of this test, it uses the same code as move) */
if(H5Lcopy(fid1, "elink/elink/elink", fid1,
- "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ "elink/elink/elink_copied", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
if(H5Lcopy(fid1, "elink/elink/elink", fid1,
- "elink/elink/elink/elink_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR
+ "elink/elink/elink/elink_copied2", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR
/* Test H5Gset and get comment */
- if(H5Gset_comment(fid1, "elink/elink/elink/group1_moved", "comment") < 0) TEST_ERROR
- if(H5Gget_comment(fid1, "elink/elink/elink/group1_moved", sizeof(buf), buf) < 0) TEST_ERROR
+ if(H5Oset_comment(fid1, "elink/elink/elink/group1_moved", "comment", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(H5Oget_comment(fid1, "elink/elink/elink/group1_moved", buf, sizeof(buf), H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ if(HDstrcmp(buf, "comment")) TEST_ERROR
/* Test H5*open */
if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((tid = H5Topen(fid1, "elink/elink/elink/type1_moved")) < 0) TEST_ERROR
- if((did = H5Dopen(fid1, "elink/elink/elink/dataset1_moved")) < 0) TEST_ERROR
+ if((tid = H5Topen(fid1, "elink/elink/elink/type1_moved")) < 0) FAIL_STACK_ERROR
+ if((did = H5Dopen(fid1, "elink/elink/elink/dataset1_moved")) < 0) FAIL_STACK_ERROR
/* Close objects */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Tclose(tid) < 0) TEST_ERROR
- if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
/* Test H5*open2 */
if((gid = H5Gopen2(fid1, "elink/elink/elink/group1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
- if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
+ if((tid = H5Topen2(fid1, "elink/elink/elink/type1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ if((did = H5Dopen2(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
/* Close objects */
- if(H5Gclose(gid) < 0) TEST_ERROR
- if(H5Tclose(tid) < 0) TEST_ERROR
- if(H5Dclose(did) < 0) TEST_ERROR
+ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR
+ if(H5Tclose(tid) < 0) FAIL_STACK_ERROR
+ if(H5Dclose(did) < 0) FAIL_STACK_ERROR
/* Test H5Oopen */
if((did = H5Oopen(fid1, "elink/elink/elink/dataset1_moved", H5P_DEFAULT)) < 0) TEST_ERROR
diff --git a/test/stab.c b/test/stab.c
index 2aed346..e3cfa57 100644
--- a/test/stab.c
+++ b/test/stab.c
@@ -111,7 +111,7 @@ test_misc(hid_t fapl, hbool_t new_format)
if((g1 = H5Gcreate2(fid, "test_1a", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((g2 = H5Gcreate2(g1, "sub_1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
if((g3 = H5Gcreate2(fid, "test_1b", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gset_comment(g3, ".", "hello world") < 0) TEST_ERROR
+ if(H5Oset_comment(g3, ".", "hello world", H5P_DEFAULT) < 0) TEST_ERROR
if(H5Gclose(g1) < 0) TEST_ERROR
if(H5Gclose(g2) < 0) TEST_ERROR
if(H5Gclose(g3) < 0) TEST_ERROR
@@ -120,7 +120,7 @@ test_misc(hid_t fapl, hbool_t new_format)
if((g1 = H5Gopen2(fid, "/test_1a", H5P_DEFAULT)) < 0) TEST_ERROR
if((g2 = H5Gopen2(fid, "/test_1a/sub_1", H5P_DEFAULT)) < 0) TEST_ERROR
if((g3 = H5Gopen2(fid, "/test_1b", H5P_DEFAULT)) < 0) TEST_ERROR
- if(H5Gget_comment(g3, "././.", sizeof comment, comment) < 0) TEST_ERROR
+ if(H5Oget_comment(g3, "././.", comment, sizeof comment, H5P_DEFAULT) < 0) TEST_ERROR
if(HDstrcmp(comment, "hello world")) {
H5_FAILED();
puts(" Read the wrong comment string from the group.");
diff --git a/test/trefer.c b/test/trefer.c
index 14fc184..6ea69fd 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -110,8 +110,8 @@ test_reference_obj(void)
CHECK(group, FAIL, "H5Gcreate2");
/* Set group's comment */
- ret=H5Gset_comment(group,".",write_comment);
- CHECK(ret, FAIL, "H5Gset_comment");
+ ret=H5Oset_comment(group, ".", write_comment, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oset_comment");
/* Create a dataset (inside Group1) */
dataset=H5Dcreate(group,"Dataset1",H5T_NATIVE_UINT,sid1,H5P_DEFAULT);
@@ -245,8 +245,8 @@ test_reference_obj(void)
CHECK(group, FAIL, "H5Rdereference");
/* Get group's comment */
- ret = H5Gget_comment(group, ".", (size_t)10, read_comment);
- CHECK(ret, FAIL, "H5Gget_comment");
+ ret = H5Oget_comment(group, ".", read_comment, (size_t)10, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_comment");
/* Check for correct comment value */
if(HDstrcmp(write_comment, read_comment) != 0)
diff --git a/test/tunicode.c b/test/tunicode.c
index b959da1..788c8a3 100644
--- a/test/tunicode.c
+++ b/test/tunicode.c
@@ -397,10 +397,10 @@ void test_objnames(hid_t fid, const char* string)
/* Set a comment on the group to test that we can access the group
* Also test that UTF-8 comments can be read.
*/
- ret = H5Gset_comment(fid, string, string);
- CHECK(ret, FAIL, "H5Gset_comment");
- ret = H5Gget_comment(fid, string, (size_t)MAX_STRING_LENGTH, read_buf);
- CHECK(ret, FAIL, "H5Gget_comment");
+ ret = H5Oset_comment(fid, string, string, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oset_comment");
+ ret = H5Oget_comment(fid, string, read_buf, (size_t)MAX_STRING_LENGTH, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Oget_comment");
ret = H5Gclose(grp_id);
CHECK(ret, FAIL, "H5Gclose");
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index 0f863f8..d8fe56b 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -2291,21 +2291,21 @@ dump_oid(hid_t oid)
*
*-------------------------------------------------------------------------
*/
-
-static void dump_comment(hid_t obj_id)
+static void
+dump_comment(hid_t obj_id)
{
char comment[50];
comment[0] = '\0';
- H5Gget_comment(obj_id, ".", sizeof(comment), comment);
+ H5Oget_comment(obj_id, ".", comment, sizeof(comment), H5P_DEFAULT);
- if (comment[0]) {
+ if(comment[0]) {
indentation(indent);
printf("COMMENT \"%s\"\n", comment);
- }
-}
-
+ } /* end if */
+} /* end dump_comment() */
+
/*-------------------------------------------------------------------------
* Function: dump_fill_value
*
diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c
index 914cfbf..e6d0d6d 100644
--- a/tools/h5dump/h5dumpgentest.c
+++ b/tools/h5dump/h5dumpgentest.c
@@ -1643,12 +1643,12 @@ static void gent_objref(void)
*tbuf; /* temp. buffer read from disk */
uint32_t *tu32; /* Temporary pointer to uint32 data */
int i; /* counting variables */
- const char *write_comment="Foo!"; /* Comments for group */
+ const char *write_comment = "Foo!"; /* Comments for group */
/* Allocate write & read buffers */
- wbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1);
- rbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1);
- tbuf=malloc(sizeof(hobj_ref_t)*SPACE1_DIM1);
+ wbuf = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
+ rbuf = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
+ tbuf = malloc(sizeof(hobj_ref_t) * SPACE1_DIM1);
/* Create file */
fid1 = H5Fcreate(FILE16, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -1660,38 +1660,38 @@ static void gent_objref(void)
group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
/* Set group's comment */
- H5Gset_comment(group,".",write_comment);
+ H5Oset_comment(group, ".", write_comment, H5P_DEFAULT);
/* Create a dataset (inside Group1) */
- dataset=H5Dcreate(group,"Dataset1",H5T_STD_U32BE,sid1,H5P_DEFAULT);
+ dataset = H5Dcreate(group, "Dataset1", H5T_STD_U32BE, sid1, H5P_DEFAULT);
- for(tu32=(uint32_t *)((void*)wbuf),i=0; i<SPACE1_DIM1; i++)
- *tu32++=i*3;
+ for(tu32 = (uint32_t *)((void*)wbuf), i = 0; i < SPACE1_DIM1; i++)
+ *tu32++ = i * 3;
/* Write selection to disk */
- H5Dwrite(dataset,H5T_NATIVE_UINT,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf);
+ H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
/* Close Dataset */
H5Dclose(dataset);
/* Create another dataset (inside Group1) */
- dataset=H5Dcreate(group,"Dataset2",H5T_STD_U8BE,sid1,H5P_DEFAULT);
+ dataset = H5Dcreate(group, "Dataset2", H5T_STD_U8BE, sid1, H5P_DEFAULT);
/* Close Dataset */
H5Dclose(dataset);
/* Create a datatype to refer to */
- tid1 = H5Tcreate (H5T_COMPOUND, sizeof(s1_t));
+ tid1 = H5Tcreate(H5T_COMPOUND, sizeof(s1_t));
/* Insert fields */
- H5Tinsert (tid1, "a", HOFFSET(s1_t,a), H5T_STD_I32BE);
+ H5Tinsert(tid1, "a", HOFFSET(s1_t,a), H5T_STD_I32BE);
- H5Tinsert (tid1, "b", HOFFSET(s1_t,b), H5T_IEEE_F32BE);
+ H5Tinsert(tid1, "b", HOFFSET(s1_t,b), H5T_IEEE_F32BE);
- H5Tinsert (tid1, "c", HOFFSET(s1_t,c), H5T_IEEE_F32BE);
+ H5Tinsert(tid1, "c", HOFFSET(s1_t,c), H5T_IEEE_F32BE);
/* Save datatype for later */
- H5Tcommit (group, "Datatype1", tid1);
+ H5Tcommit(group, "Datatype1", tid1);
/* Close datatype */
H5Tclose(tid1);
@@ -1700,22 +1700,22 @@ static void gent_objref(void)
H5Gclose(group);
/* Create a dataset */
- dataset=H5Dcreate(fid1,"Dataset3",H5T_STD_REF_OBJ,sid1,H5P_DEFAULT);
+ dataset = H5Dcreate(fid1, "Dataset3", H5T_STD_REF_OBJ, sid1, H5P_DEFAULT);
/* Create reference to dataset */
- H5Rcreate(&wbuf[0],fid1,"/Group1/Dataset1",H5R_OBJECT,-1);
+ H5Rcreate(&wbuf[0], fid1, "/Group1/Dataset1", H5R_OBJECT, -1);
/* Create reference to dataset */
- H5Rcreate(&wbuf[1],fid1,"/Group1/Dataset2",H5R_OBJECT,-1);
+ H5Rcreate(&wbuf[1], fid1, "/Group1/Dataset2", H5R_OBJECT, -1);
/* Create reference to group */
- H5Rcreate(&wbuf[2],fid1,"/Group1",H5R_OBJECT,-1);
+ H5Rcreate(&wbuf[2], fid1, "/Group1", H5R_OBJECT, -1);
/* Create reference to named datatype */
- H5Rcreate(&wbuf[3],fid1,"/Group1/Datatype1",H5R_OBJECT,-1);
+ H5Rcreate(&wbuf[3], fid1, "/Group1/Datatype1", H5R_OBJECT, -1);
/* Write selection to disk */
- H5Dwrite(dataset,H5T_STD_REF_OBJ,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf);
+ H5Dwrite(dataset, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf);
/* Close disk dataspace */
H5Sclose(sid1);
@@ -1730,7 +1730,6 @@ static void gent_objref(void)
free(wbuf);
free(rbuf);
free(tbuf);
-
}
static void gent_datareg(void)
@@ -2870,7 +2869,8 @@ static void gent_empty(void)
assert(ret>=0);
}
-static void gent_group_comments(void)
+static void
+gent_group_comments(void)
{
hid_t fid, group;
@@ -2878,51 +2878,51 @@ static void gent_group_comments(void)
/* / */
group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g1", "Comment for group /g1");
+ H5Oset_comment(group, "/g1", "Comment for group /g1", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g2", "Comment for group /g2");
+ H5Oset_comment(group, "/g2", "Comment for group /g2", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g3", "Comment for group /g3");
+ H5Oset_comment(group, "/g3", "Comment for group /g3", H5P_DEFAULT);
H5Gclose(group);
/* /g1 */
group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g1/g1.1", "Comment for group /g1/g1.1");
+ H5Oset_comment(group, "/g1/g1.1", "Comment for group /g1/g1.1", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g1/g1.2", "Comment for group /g1/g1.2");
+ H5Oset_comment(group, "/g1/g1.2", "Comment for group /g1/g1.2", H5P_DEFAULT);
H5Gclose(group);
/* /g2 */
group = H5Gcreate2(fid, "/g2/g2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g2/g2.1", "Comment for group /g2/g2.1");
+ H5Oset_comment(group, "/g2/g2.1", "Comment for group /g2/g2.1", H5P_DEFAULT);
H5Gclose(group);
/* /g3 */
group = H5Gcreate2(fid, "/g3/g3.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g3/g3.1", "Comment for group /g3/g3.1");
+ H5Oset_comment(group, "/g3/g3.1", "Comment for group /g3/g3.1", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g3/g3.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g3/g3.2", "Comment for group /g3/g3.2");
+ H5Oset_comment(group, "/g3/g3.2", "Comment for group /g3/g3.2", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g3/g3.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g3/g3.3", "Comment for group /g3/g3.3");
+ H5Oset_comment(group, "/g3/g3.3", "Comment for group /g3/g3.3", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g3/g3.4", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g3/g3.4", "Comment for group /g3/g3.4");
+ H5Oset_comment(group, "/g3/g3.4", "Comment for group /g3/g3.4", H5P_DEFAULT);
H5Gclose(group);
/* /g2/g2.1 */
group = H5Gcreate2(fid, "/g2/g2.1/g2.1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1");
+ H5Oset_comment(group, "/g2/g2.1/g2.1.1", "Comment for group /g2/g2.1/g2.1.1", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g2/g2.1/g2.1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2");
+ H5Oset_comment(group, "/g2/g2.1/g2.1.2", "Comment for group /g2/g2.1/g2.1.2", H5P_DEFAULT);
H5Gclose(group);
group = H5Gcreate2(fid, "/g2/g2.1/g2.1.3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- H5Gset_comment(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3");
+ H5Oset_comment(group, "/g2/g2.1/g2.1.3", "Comment for group /g2/g2.1/g2.1.3", H5P_DEFAULT);
H5Gclose(group);
H5Fclose(fid);
@@ -4654,8 +4654,8 @@ static void gent_filters(void)
ret=make_dset(fid,"compact",sid,H5T_NATIVE_INT,dcpl,buf1);
assert(ret>=0);
- ret=H5Gset_comment(fid,"compact", "This is a dataset with compact storage");
- assert(ret>=0);
+ ret = H5Oset_comment(fid, "compact", "This is a dataset with compact storage", H5P_DEFAULT);
+ assert(ret >= 0);
ret=H5Pset_layout(dcpl, H5D_CONTIGUOUS);
assert(ret>=0);
@@ -4663,8 +4663,8 @@ static void gent_filters(void)
ret=make_dset(fid,"contiguous",sid,H5T_NATIVE_INT,dcpl,buf1);
assert(ret>=0);
- ret=H5Gset_comment(fid,"contiguous", "This is a dataset with contiguous storage");
- assert(ret>=0);
+ ret = H5Oset_comment(fid, "contiguous", "This is a dataset with contiguous storage", H5P_DEFAULT);
+ assert(ret >= 0);
ret=H5Pset_layout(dcpl, H5D_CHUNKED);
assert(ret>=0);
@@ -4675,8 +4675,8 @@ static void gent_filters(void)
ret=make_dset(fid,"chunked",sid,H5T_NATIVE_INT,dcpl,buf1);
assert(ret>=0);
- ret=H5Gset_comment(fid,"chunked", "This is a dataset with chunked storage");
- assert(ret>=0);
+ ret = H5Oset_comment(fid, "chunked", "This is a dataset with chunked storage", H5P_DEFAULT);
+ assert(ret >= 0);
/*-------------------------------------------------------------------------
* make several dataset with filters
@@ -4906,8 +4906,8 @@ static void gent_filters(void)
ret=H5Tcommit(fid, "mytype", tid);
assert(ret>=0);
- ret=H5Gset_comment(fid,"mytype", "This is a commited datatype");
- assert(ret>=0);
+ ret = H5Oset_comment(fid, "mytype", "This is a commited datatype", H5P_DEFAULT);
+ assert(ret >= 0);
ret=H5Tclose(tid);
assert(ret>=0);
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index f127f3f..9dce3f9 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -1894,40 +1894,42 @@ list (hid_t group, const char *name, void *_iter)
/* Show detailed information about the object, beginning with information
* which is common to all objects. */
- if (verbose_g>0 && H5G_LINK!=sb.type && H5G_UDLINK!=sb.type) {
- if (sb.type>=0)
+ if(verbose_g > 0 && H5G_LINK != sb.type && H5G_UDLINK != sb.type) {
+ if(sb.type >= 0)
H5Aiterate(obj, NULL, list_attr, NULL);
printf(" %-10s %lu:"H5_PRINTF_HADDR_FMT"\n", "Location:", sb.fileno[0], objno);
printf(" %-10s %u\n", "Links:", sb.nlink);
- if (sb.mtime>0) {
- if (simple_output_g) tm=gmtime(&(sb.mtime));
- else tm=localtime(&(sb.mtime));
- if (tm) {
- strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
+ if(sb.mtime > 0) {
+ if(simple_output_g)
+ tm = HDgmtime(&(sb.mtime));
+ else
+ tm = HDlocaltime(&(sb.mtime));
+ if(tm) {
+ HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
printf(" %-10s %s\n", "Modified:", buf);
- }
- }
+ } /* end if */
+ } /* end if */
comment[0] = '\0';
- H5Gget_comment(group, name, sizeof(comment), comment);
- strcpy(comment+sizeof(comment)-4, "...");
- if (comment[0]) {
+ H5Oget_comment(group, name, comment, sizeof(comment), H5P_DEFAULT);
+ HDstrcpy(comment + sizeof(comment) - 4, "...");
+ if(comment[0]) {
printf(" %-10s \"", "Comment:");
display_string(stdout, comment, FALSE);
puts("\"");
- }
- }
- if (sb.type>=0 && dispatch_g[sb.type].list2) {
+ } /* end if */
+ } /* end if */
+ if(sb.type>=0 && dispatch_g[sb.type].list2)
(dispatch_g[sb.type].list2)(obj, fullname);
- }
- /* Close the object. */
done:
- if (sb.type>=0 && obj>=0 && dispatch_g[sb.type].close) {
+ /* Close the object. */
+ if(sb.type >= 0 && obj >= 0 && dispatch_g[sb.type].close)
(dispatch_g[sb.type].close)(obj);
- }
- if (fullname) free(fullname);
+
+ if (fullname)
+ free(fullname);
return 0;
-}
+} /* end list() */
/*-------------------------------------------------------------------------