summaryrefslogtreecommitdiffstats
path: root/src/H5O.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-11-01 18:24:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-11-01 18:24:08 (GMT)
commit24f2310b1284c569ea277be00f57248bfd306378 (patch)
treea28e3e8ec585c963f73fc4ed1294f30f940e3a34 /src/H5O.c
parentecaf22fa0450205a508c961b59dbe616d0449b0a (diff)
downloadhdf5-24f2310b1284c569ea277be00f57248bfd306378.zip
hdf5-24f2310b1284c569ea277be00f57248bfd306378.tar.gz
hdf5-24f2310b1284c569ea277be00f57248bfd306378.tar.bz2
[svn-r14229] Description:
Change H5O[gs]et_comment to H5O[gs]et_comment_by_name and re-add simpler forms of H5O[gs]et_comment. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'src/H5O.c')
-rw-r--r--src/H5O.c90
1 files changed, 84 insertions, 6 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 681413e..15cafc5 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -42,6 +42,7 @@
#include "H5Fpkg.h" /* File access */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
#include "H5MFprivate.h" /* File memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared object header messages */
@@ -673,13 +674,52 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Oset_comment(hid_t loc_id, const char *name, const char *comment,
- hid_t lapl_id)
+H5Oset_comment(hid_t obj_id, const char *comment)
{
H5G_loc_t loc; /* Location of group */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(H5Oset_comment, FAIL)
+ H5TRACE2("e", "i*s", obj_id, comment);
+
+ /* Check args */
+ if(H5G_loc(obj_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+
+ /* (Re)set the object's comment */
+ if(H5G_loc_set_comment(&loc, ".", comment, H5P_LINK_ACCESS_DEFAULT, 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: H5Oset_comment_by_name
+ *
+ * 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_by_name(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_by_name, FAIL)
H5TRACE4("e", "i*s*si", loc_id, name, comment, lapl_id);
/* Check args */
@@ -699,7 +739,7 @@ H5Oset_comment(hid_t loc_id, const char *name, const char *comment,
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Oset_comment() */
+} /* end H5Oset_comment_by_name() */
/*-------------------------------------------------------------------------
@@ -719,13 +759,51 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5Oget_comment(hid_t loc_id, const char *name, char *comment, size_t bufsize,
- hid_t lapl_id)
+H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize)
{
H5G_loc_t loc; /* Location of group */
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(H5Oget_comment, FAIL)
+ H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize);
+
+ /* Check args */
+ if(H5G_loc(obj_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+
+ /* Retrieve the object's comment */
+ if((ret_value = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, H5P_LINK_ACCESS_DEFAULT, 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: H5Oget_comment_by_name
+ *
+ * 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_by_name(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_by_name, FAIL)
H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id);
/* Check args */
@@ -745,7 +823,7 @@ H5Oget_comment(hid_t loc_id, const char *name, char *comment, size_t bufsize,
done:
FUNC_LEAVE_API(ret_value)
-} /* end H5Oget_comment() */
+} /* end H5Oget_comment_by_name() */
/*-------------------------------------------------------------------------