summaryrefslogtreecommitdiffstats
path: root/src/H5G.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1998-07-23 21:19:17 (GMT)
committerRobb Matzke <matzke@llnl.gov>1998-07-23 21:19:17 (GMT)
commitc8d2f1e17a828016487bb7661f3eff4135c92226 (patch)
treeb20e7514d7cf64ba6f8b21723b8e45bd4235f346 /src/H5G.c
parent8821a3c0156e28a7fd49508c0b471361a9344984 (diff)
downloadhdf5-c8d2f1e17a828016487bb7661f3eff4135c92226.zip
hdf5-c8d2f1e17a828016487bb7661f3eff4135c92226.tar.gz
hdf5-c8d2f1e17a828016487bb7661f3eff4135c92226.tar.bz2
[svn-r537] Changes since 19980722
---------------------- ./src/H5A.c ./src/H5Apublic.h ./test/tattr.c Switched the order of the second and third argument of H5Aget_name() to make it consistent with other functions that take buffers and buffer sizes. ./src/H5G.c ./src/H5Gpublic.h ./src/H5Gprivate.h The H5Gget_comment() function returns the size of the comment including the null terminator. If the object has no comment then zero is returned. If an error occurs then a negative value is returned. ./MANIFEST ./tools/Makefile.in ./tools/h5tools.h [NEW] ./tools/h5dump.c [NEW] Created a library for printing values of datasets in a way that looks nice. It's not done yet, but I needed it for debugging the contents of files from Jim Reus. ./tools/h5ls.c Added the `-d' and `--dump' options which cause the contents of a dataset to be printed. Added `-w N' and `--width=N' options to control how wide the raw data output should be. If you want single-column output then say `-w1'. Printing dataset values can now handle datasets of any integer or floating point atomic type. As a special case, integers which are one byte wide are treated a character strings for now. Sample output: $ h5ls --dump --width=60 banana.hdf ARCHIVE 0:0:0:744 Dataset {52/Inf} Data: (0) "U struct complex { double R; double I; };\012V" (43) " double;\012" U 0:0:0:2500 Dataset {256/512} Data: printing of compound data types is not implemented yet V 0:0:0:3928 Dataset {256/512} Data: (0) 0, 0.015625, 0.03125, 0.046875, 0.0625, (5) 0.078125, 0.09375, 0.109375, 0.125, 0.140625, (10) 0.15625, 0.171875, 0.1875, 0.203125, 0.21875, (15) 0.234375, 0.25, 0.265625, 0.28125, 0.296875, ...
Diffstat (limited to 'src/H5G.c')
-rw-r--r--src/H5G.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 2e24a15..c875814 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -767,9 +767,12 @@ H5Gset_comment (hid_t loc_id, const char *name, const char *comment)
* specified object. If BUFSIZE is large enough to hold the
* entire comment then the comment string will be null
* terminated, otherwise it will not. If the object does not
- * have a comment value then the empty string is returned.
+ * have a comment value then no bytes are copied to the BUF
+ * buffer.
*
- * Return: Success: SUCCEED
+ * Return: Success: Number of characters in the comment counting
+ * the null terminator. The value returned may
+ * be larger than the BUFSIZE argument.
*
* Failure: FAIL
*
@@ -780,13 +783,14 @@ H5Gset_comment (hid_t loc_id, const char *name, const char *comment)
*
*-------------------------------------------------------------------------
*/
-herr_t
+int
H5Gget_comment (hid_t loc_id, const char *name, size_t bufsize, char *buf)
{
H5G_t *loc = NULL;
+ intn retval = FAIL;
FUNC_ENTER(H5Gget_comment, FAIL);
- H5TRACE4("e","iszs",loc_id,name,bufsize,buf);
+ H5TRACE4("Is","iszs",loc_id,name,bufsize,buf);
if (NULL==(loc=H5G_loc(loc_id))) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
@@ -794,16 +798,16 @@ H5Gget_comment (hid_t loc_id, const char *name, size_t bufsize, char *buf)
if (!name || !*name) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
}
- if (bufsize<1 || !buf) {
+ if (bufsize>0 && !buf) {
HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified");
}
- if (H5G_get_comment(loc, name, bufsize, buf)<0) {
+ if ((retval=H5G_get_comment(loc, name, bufsize, buf))<0) {
HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
"unable to set comment value");
}
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE(retval);
}
/*
@@ -2131,7 +2135,9 @@ H5G_set_comment(H5G_t *loc, const char *name, const char *buf)
*
* Purpose: Get the comment value for an object.
*
- * Return: Success: SUCCEED
+ * Return: Success: Number of bytes in the comment including the
+ * null terminator. Zero if the object has no
+ * comment.
*
* Failure: FAIL
*
@@ -2142,11 +2148,12 @@ H5G_set_comment(H5G_t *loc, const char *name, const char *buf)
*
*-------------------------------------------------------------------------
*/
-herr_t
+intn
H5G_get_comment(H5G_t *loc, const char *name, size_t bufsize, char *buf)
{
H5O_name_t comment;
H5G_entry_t obj_ent;
+ intn retval = FAIL;
FUNC_ENTER(H5G_get_comment, FAIL);
@@ -2159,12 +2166,14 @@ H5G_get_comment(H5G_t *loc, const char *name, size_t bufsize, char *buf)
/* Get the message */
comment.s = NULL;
if (NULL==H5O_read(&obj_ent, H5O_NAME, 0, &comment)) {
- buf[0] = '\0';
+ if (buf && bufsize>0) buf[0] = '\0';
+ retval = 0;
} else {
strncpy(buf, comment.s, bufsize);
+ retval = strlen(comment.s);
H5O_reset(H5O_NAME, &comment);
}
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE(retval);
}