diff options
author | Robb Matzke <matzke@llnl.gov> | 1998-07-20 21:01:32 (GMT) |
---|---|---|
committer | Robb Matzke <matzke@llnl.gov> | 1998-07-20 21:01:32 (GMT) |
commit | 2423411a647cff2bc2c37789fc9973ed4a683348 (patch) | |
tree | 562aba5c2f3d8aabf164d81122b8531947dd4b68 /src | |
parent | 00aa39c66f9e6a7cdf594533eadfaac74896898b (diff) | |
download | hdf5-2423411a647cff2bc2c37789fc9973ed4a683348.zip hdf5-2423411a647cff2bc2c37789fc9973ed4a683348.tar.gz hdf5-2423411a647cff2bc2c37789fc9973ed4a683348.tar.bz2 |
[svn-r522] Changes since 19980720
----------------------
./src/H5Gpublic.h
./src/H5Gprivate.h
./src/H5G.c
./test/dsets.c
./doc/html/Groups.html
Added the H5Gset_comment() and H5Gget_comment() functions
described in an earlier e-mail.
./src/H5.c
Fixed a bug in the tracing code that caused certain data space
enum types to not be printed. Nested case statements can get
confusing to the eyes!
./tools/h5ls.c
Prints the first 50 bytes or so of object comments.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 104 | ||||
-rw-r--r-- | src/H5G.c | 179 | ||||
-rw-r--r-- | src/H5Gprivate.h | 3 | ||||
-rw-r--r-- | src/H5Gpublic.h | 3 |
4 files changed, 237 insertions, 52 deletions
@@ -1386,6 +1386,58 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) } break; + case 'S': + switch (type[1]) { + case 'c': + if (ptr) { + fprintf(out, "0x%lx", (unsigned long)vp); + } else { + H5S_class_t cls = va_arg(ap, H5S_class_t); + switch (cls) { + case H5S_NO_CLASS: + fprintf(out, "H5S_NO_CLASS"); + break; + case H5S_SCALAR: + fprintf(out, "H5S_SCALAR"); + break; + case H5S_SIMPLE: + fprintf(out, "H5S_SIMPLE"); + break; + case H5S_COMPLEX: + fprintf(out, "H5S_COMPLEX"); + break; + default: + fprintf(out, "%ld", (long)cls); + break; + } + } + break; + + case 's': + if (ptr) { + fprintf(out, "0x%lx", (unsigned long)vp); + } else { + H5S_seloper_t so = va_arg(ap, H5S_seloper_t); + switch (so) { + case H5S_NOOP: + fprintf(out, "H5S_NOOP"); + break; + case H5S_SELECT_SET: + fprintf(out, "H5S_SELECT_SET"); + break; + default: + fprintf(out, "%ld", (long)so); + break; + } + } + break; + + default: + fprintf(out, "BADTYPE(S%c)", type[1]); + goto error; + } + break; + case 's': if (ptr) { fprintf (out, "0x%lx", (unsigned long)vp); @@ -1516,58 +1568,6 @@ H5_trace (hbool_t returning, const char *func, const char *type, ...) } break; - case 'S': - switch (type[1]) { - case 'c': - if (ptr) { - fprintf(out, "0x%lx", (unsigned long)vp); - } else { - H5S_class_t cls = va_arg(ap, H5S_class_t); - switch (cls) { - case H5S_NO_CLASS: - fprintf(out, "H5S_NO_CLASS"); - break; - case H5S_SCALAR: - fprintf(out, "H5S_SCALAR"); - break; - case H5S_SIMPLE: - fprintf(out, "H5S_SIMPLE"); - break; - case H5S_COMPLEX: - fprintf(out, "H5S_COMPLEX"); - break; - default: - fprintf(out, "%ld", (long)cls); - break; - } - } - break; - - case 's': - if (ptr) { - fprintf(out, "0x%lx", (unsigned long)vp); - } else { - H5S_seloper_t so = va_arg(ap, H5S_seloper_t); - switch (so) { - case H5S_NOOP: - fprintf(out, "H5S_NOOP"); - break; - case H5S_SELECT_SET: - fprintf(out, "H5S_SELECT_SET"); - break; - default: - fprintf(out, "%ld", (long)so); - break; - } - } - break; - - default: - fprintf(out, "BADTYPE(F%c)", type[1]); - goto error; - } - break; - case 't': if (ptr) { fprintf (out, "0x%lx", (unsigned long)vp); @@ -716,6 +716,96 @@ H5Gget_linkval (hid_t loc_id, const char *name, size_t size, char *buf/*out*/) FUNC_LEAVE (SUCCEED); } + +/*------------------------------------------------------------------------- + * Function: H5Gset_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. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, July 20, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gset_comment (hid_t loc_id, const char *name, const char *comment) +{ + H5G_t *loc = NULL; + + FUNC_ENTER(H5Gset_comment, FAIL); + H5TRACE3("e","iss",loc_id,name,comment); + + if (NULL==(loc=H5G_loc(loc_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + } + if (!name || !*name) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); + } + + if (H5G_set_comment(loc, name, comment)<0) { + HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, + "unable to set comment value"); + } + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5Gget_comment + * + * Purpose: Return at most BUFSIZE characters of the comment for the + * 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. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, July 20, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Gget_comment (hid_t loc_id, const char *name, size_t bufsize, char *buf) +{ + H5G_t *loc = NULL; + + FUNC_ENTER(H5Gget_comment, FAIL); + H5TRACE4("e","iszs",loc_id,name,bufsize,buf); + + if (NULL==(loc=H5G_loc(loc_id))) { + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location"); + } + if (!name || !*name) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified"); + } + if (bufsize<1 || !buf) { + HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified"); + } + + if (H5G_get_comment(loc, name, bufsize, buf)<0) { + HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, + "unable to set comment value"); + } + + FUNC_LEAVE(SUCCEED); +} + /* *------------------------------------------------------------------------- *------------------------------------------------------------------------- @@ -1988,4 +2078,93 @@ H5G_linkval (H5G_t *loc, const char *name, size_t size, char *buf/*out*/) FUNC_LEAVE (SUCCEED); } + +/*------------------------------------------------------------------------- + * Function: H5G_set_comment + * + * Purpose: (Re)sets the comment for an object. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, July 20, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_set_comment(H5G_t *loc, const char *name, const char *buf) +{ + H5G_entry_t obj_ent; + H5O_name_t comment; + + FUNC_ENTER(H5G_set_comment, FAIL); + + /* Get the symbol table entry for the object */ + if (H5G_namei(H5G_entof(loc), name, NULL, NULL, &obj_ent/*out*/, + TRUE, NULL)<0) { + HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); + } + + /* Remove the previous comment message if any */ + if (H5O_remove(&obj_ent, H5O_NAME, 0)<0) H5E_clear(); + + /* Add the new message */ + if (buf && *buf) { + comment.s = H5MM_xstrdup(buf); + if (H5O_modify(&obj_ent, H5O_NAME, H5O_NEW_MESG, 0, &comment)<0) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, + "unable to set comment object header message"); + } + H5O_reset(H5O_NAME, &comment); + } + + FUNC_LEAVE(SUCCEED); +} + + +/*------------------------------------------------------------------------- + * Function: H5G_get_comment + * + * Purpose: Get the comment value for an object. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Monday, July 20, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_get_comment(H5G_t *loc, const char *name, size_t bufsize, char *buf) +{ + H5O_name_t comment; + H5G_entry_t obj_ent; + + FUNC_ENTER(H5G_get_comment, FAIL); + + /* Get the symbol table entry for the object */ + if (H5G_namei(H5G_entof(loc), name, NULL, NULL, &obj_ent/*out*/, + TRUE, NULL)<0) { + HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found"); + } + + /* Get the message */ + comment.s = NULL; + if (NULL==H5O_read(&obj_ent, H5O_NAME, 0, &comment)) { + buf[0] = '\0'; + } else { + strncpy(buf, comment.s, bufsize); + H5O_reset(H5O_NAME, &comment); + } + + FUNC_LEAVE(SUCCEED); +} diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 0f8f773..b0ee5e8 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -117,6 +117,9 @@ herr_t H5G_stat (H5G_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); herr_t H5G_linkval (H5G_t *loc, const char *name, size_t size, char *buf/*out*/); +herr_t H5G_set_comment(H5G_t *loc, const char *name, const char *buf); +herr_t H5G_get_comment(H5G_t *loc, const char *name, size_t bufsize, + char *buf); herr_t H5G_insert (H5G_t *cwg, const char *name, H5G_entry_t *ent); herr_t H5G_find (H5G_t *cwg, const char *name, H5G_entry_t *grp_ent/*out*/, H5G_entry_t *ent/*out*/); diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index d70dac7..d801a31 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -69,6 +69,9 @@ herr_t H5Gstat (hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/); herr_t H5Gget_linkval (hid_t loc_id, const char *name, size_t size, char *buf/*out*/); +herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment); +herr_t H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, + char *buf); #ifdef __cplusplus } |