summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5G.c61
-rw-r--r--src/H5Gent.c35
-rw-r--r--src/H5Gprivate.h5
-rw-r--r--src/H5R.c6
-rw-r--r--test/links.c24
-rw-r--r--tools/h5dump/h5dump.c104
-rw-r--r--tools/h5dump/h5dump.h15
-rw-r--r--tools/h5ls/h5ls.c218
8 files changed, 252 insertions, 216 deletions
diff --git a/src/H5G.c b/src/H5G.c
index 07e61a7..eff793d 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -184,20 +184,20 @@ static htri_t H5G_link_isa(H5G_entry_t *ent, hid_t dxpl_id);
static H5G_t * H5G_open_oid(H5G_entry_t *ent, hid_t dxpl_id);
static H5G_t *H5G_rootof(H5F_t *f);
static herr_t H5G_link(H5G_entry_t *cur_loc, const char *cur_name,
- H5G_entry_t *new_loc, const char *new_name,
- H5G_link_t type, unsigned namei_flags, hid_t dxpl_id);
+ H5G_entry_t *new_loc, const char *new_name, H5G_link_t type,
+ unsigned namei_flags, hid_t dxpl_id);
static herr_t H5G_get_num_objs(H5G_entry_t *grp, hsize_t *num_objs, hid_t dxpl_id);
static ssize_t H5G_get_objname_by_idx(H5G_entry_t *loc, hsize_t idx, char* name, size_t size, hid_t dxpl_id);
static H5G_obj_t H5G_get_objtype_by_idx(H5G_entry_t *loc, hsize_t idx, hid_t dxpl_id);
static herr_t H5G_linkval(H5G_entry_t *loc, const char *name, size_t size,
- char *buf/*out*/, hid_t dxpl_id);
+ char *buf/*out*/, hid_t dxpl_id);
static herr_t H5G_set_comment(H5G_entry_t *loc, const char *name,
- const char *buf, hid_t dxpl_id);
+ const char *buf, hid_t dxpl_id);
static int H5G_get_comment(H5G_entry_t *loc, const char *name,
- size_t bufsize, char *buf, hid_t dxpl_id);
+ size_t bufsize, char *buf, hid_t dxpl_id);
static herr_t H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id);
static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name,
- H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_it);
+ H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_id);
static htri_t H5G_common_path(const H5RS_str_t *fullpath_r,
const H5RS_str_t *prefix_r);
static H5RS_str_t *H5G_build_fullpath(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r);
@@ -1501,12 +1501,11 @@ H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/
loc_ent=&(tmp_grp->ent);
} /* end if */
- /* Deep copy of the symbol table entry */
+ /* Deep copy of the symbol table entry (duplicates strings) */
if (H5G_ent_copy(obj_ent, loc_ent,H5G_COPY_DEEP)<0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
- HDmemset(grp_ent, 0, sizeof(H5G_entry_t));
- grp_ent->header = HADDR_UNDEF;
+ H5G_ent_reset(grp_ent);
/* traverse the name */
while ((name = H5G_component(name, &nchars)) && *name) {
@@ -1548,8 +1547,7 @@ H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/
/* Transfer "ownership" of the entry's information to the group entry */
H5G_ent_copy(grp_ent,obj_ent,H5G_COPY_SHALLOW);
- HDmemset(obj_ent, 0, sizeof(H5G_entry_t));
- obj_ent->header = HADDR_UNDEF;
+ H5G_ent_reset(obj_ent);
/* Set flag that we've copied a new entry into the group entry */
group_copy =1;
@@ -1577,7 +1575,7 @@ H5G_namei(const H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/
H5G_entry_t new_ent;
/* Reset group entry */
- HDmemset(&new_ent, 0, sizeof(H5G_entry_t));
+ H5G_ent_reset(&new_ent);
/* Create the group entry */
if (H5G_stab_create(grp_ent->file, dxpl_id, 0, &new_ent/*out*/) < 0)
@@ -1702,7 +1700,7 @@ H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
FUNC_ENTER_NOAPI_NOINIT(H5G_traverse_slink);
/* Portably initialize the temporary group entry */
- HDmemset(&tmp_grp_ent,0,sizeof(H5G_entry_t));
+ H5G_ent_reset(&tmp_grp_ent);
/* Get the link value */
if (NULL==H5O_read (grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id))
@@ -1806,7 +1804,7 @@ H5G_mkroot (H5F_t *f, hid_t dxpl_id, H5G_entry_t *ent)
*/
if (!ent) {
ent = &new_root;
- HDmemset(ent, 0, sizeof(H5G_entry_t));
+ H5G_ent_reset(ent);
if (H5G_stab_create (f, dxpl_id, (size_t)H5G_SIZE_HINT, ent/*out*/)<0)
HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create root group");
if (1 != H5O_link (ent, 1, dxpl_id))
@@ -2631,8 +2629,7 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
* Create a symbol table entry for the link. The object header is
* undefined and the cache contains the link-value offset.
*/
- HDmemset (&cur_obj, 0, sizeof cur_obj);
- cur_obj.header = HADDR_UNDEF;
+ H5G_ent_reset(&cur_obj);
cur_obj.file = grp_ent.file;
cur_obj.type = H5G_CACHED_SLINK;
cur_obj.cache.slink.lval_offset = offset;
@@ -2771,15 +2768,21 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
* length is specific to symbolic links.
*/
if (statbuf) {
+ /* Common code to retrieve the file's fileno */
+ if(H5F_get_fileno(obj_ent.file,&statbuf->fileno)<0)
+ HGOTO_ERROR (H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno");
+
+ /* Retrieve information specific to each type of entry */
if (H5G_CACHED_SLINK==obj_ent.type) {
H5O_stab_t stab_mesg; /* Symbol table message info */
- const H5HL_t *heap; /* Pointer to local heap for group */
const char *s; /* Pointer to link value */
+ const H5HL_t *heap; /* Pointer to local heap for group */
/* Named object is a symbolic link */
if (NULL == H5O_read(&grp_ent, H5O_STAB_ID, 0, &stab_mesg, dxpl_id))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value")
+ /* Lock the local heap */
if (NULL == (heap = H5HL_protect(grp_ent.file, dxpl_id, stab_mesg.heap_addr)))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read protect link value")
@@ -2787,6 +2790,7 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
statbuf->linklen = HDstrlen(s) + 1; /*count the null terminator*/
+ /* Release the local heap */
if (H5HL_unprotect(grp_ent.file, dxpl_id, heap, stab_mesg.heap_addr, H5AC__NO_FLAGS_SET) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read unprotect link value")
@@ -2811,10 +2815,6 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
if(H5O_get_info(&obj_ent, &(statbuf->ohdr), dxpl_id)<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object header information")
}
-
- /* Common code to retrieve the file's fileno */
- if(H5F_get_fileno(obj_ent.file,&statbuf->fileno)<0)
- HGOTO_ERROR (H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno");
} /* end if */
done:
@@ -3199,10 +3199,9 @@ static herr_t
H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
{
H5G_entry_t grp_ent, obj_ent;
- size_t len;
const char *base=NULL;
char *norm_name = NULL; /* Pointer to normalized name */
- H5G_stat_t statbuf; /* Info about object to unlink */
+ H5G_obj_t obj_type; /* Object type */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_unlink);
@@ -3216,12 +3215,8 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize name");
/* Reset the group entries to known values in a portable way */
- HDmemset(&grp_ent,0,sizeof(H5G_entry_t));
- HDmemset(&obj_ent,0,sizeof(H5G_entry_t));
-
- /* Get object type before unlink */
- if (H5G_get_objinfo(loc, norm_name, FALSE, &statbuf, dxpl_id)<0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
+ H5G_ent_reset(&grp_ent);
+ H5G_ent_reset(&obj_ent);
/* Get the entry for the group that contains the object to be unlinked */
if (H5G_namei(loc, norm_name, NULL, &grp_ent, &obj_ent,
@@ -3229,15 +3224,19 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
if (!H5F_addr_defined(grp_ent.header))
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no containing group specified");
- if (NULL==(base=H5G_basename(norm_name, &len)) || '/'==*base)
+ if (NULL==(base=H5G_basename(norm_name, NULL)) || '/'==*base)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "problems obtaining object base name");
+ /* Get object type before unlink */
+ if((obj_type = H5G_get_type(&obj_ent, dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't determine object type");
+
/* Remove the name from the symbol table */
if (H5G_stab_remove(&grp_ent, base, dxpl_id)<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to unlink name from symbol table");
/* Search the open IDs and replace names for unlinked object */
- if (H5G_replace_name(statbuf.type, &obj_ent, NULL, NULL, NULL, NULL, OP_UNLINK )<0)
+ if (H5G_replace_name(obj_type, &obj_ent, NULL, NULL, NULL, NULL, OP_UNLINK )<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name");
done:
diff --git a/src/H5Gent.c b/src/H5Gent.c
index fa58ca7..ffc7a52 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -417,7 +417,7 @@ H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5G_ent_copy_depth_t dept
dst->canon_path_r=NULL;
} else if(depth==H5G_COPY_SHALLOW) {
/* Discarding 'const' qualifier OK - QAK */
- HDmemset(src, 0, sizeof(H5G_entry_t));
+ H5G_ent_reset(src);
} /* end if */
FUNC_LEAVE_NOAPI(SUCCEED);
@@ -425,6 +425,39 @@ H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src, H5G_ent_copy_depth_t dept
/*-------------------------------------------------------------------------
+ * Function: H5G_ent_reset
+ *
+ * Purpose: Reset a symbol table entry to an empty state
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu
+ *
+ * Date: August 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_ent_reset(H5G_entry_t *ent)
+{
+ FUNC_ENTER_NOAPI_NOFUNC(H5G_ent_reset);
+
+ /* Check arguments */
+ HDassert(ent);
+
+ /* Clear the symbol table entry to an empty state */
+ HDmemset(ent, 0, sizeof(H5G_entry_t));
+ ent->header = HADDR_UNDEF;
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5G_ent_reset() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_ent_debug
*
* Purpose: Prints debugging information about a symbol table entry.
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 08ec9af..92fee2d 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -187,9 +187,10 @@ H5_DLL herr_t H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent);
H5_DLL herr_t H5G_ent_decode(H5F_t *f, const uint8_t **pp,
H5G_entry_t *ent/*out*/);
H5_DLL const H5G_cache_t *H5G_ent_cache(const H5G_entry_t *ent, H5G_type_t *cache_type);
-H5_DLL herr_t H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src,
+H5_DLL herr_t H5G_ent_copy(H5G_entry_t *dst, const H5G_entry_t *src,
H5G_ent_copy_depth_t depth);
-H5_DLL herr_t H5G_free_ent_name(H5G_entry_t *ent);
+H5_DLL herr_t H5G_ent_reset(H5G_entry_t *ent);
+H5_DLL herr_t H5G_free_ent_name(H5G_entry_t *ent);
H5_DLL herr_t H5G_ent_debug(H5F_t *f, hid_t dxpl_id, const H5G_entry_t *ent, FILE * stream,
int indent, int fwidth, haddr_t heap);
#endif
diff --git a/src/H5R.c b/src/H5R.c
index c20e21e..b06d990 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -336,7 +336,7 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref)
assert(file);
/* Initialize the symbol table entry */
- HDmemset(&ent,0,sizeof(H5G_entry_t));
+ H5G_ent_reset(&ent);
ent.type=H5G_NOTHING_CACHED;
ent.file=file;
@@ -524,7 +524,7 @@ H5R_get_region(H5F_t *file, hid_t dxpl_id, H5R_type_t UNUSED ref_type, void *_re
assert(file);
/* Initialize the symbol table entry */
- HDmemset(&ent,0,sizeof(H5G_entry_t));
+ H5G_ent_reset(&ent);
ent.type=H5G_NOTHING_CACHED;
ent.file=file;
@@ -650,7 +650,7 @@ H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, void *_ref)
assert(_ref);
/* Initialize the symbol table entry */
- HDmemset(&ent,0,sizeof(H5G_entry_t));
+ H5G_ent_reset(&ent);
ent.type=H5G_NOTHING_CACHED;
ent.file=file;
diff --git a/test/links.c b/test/links.c
index cb165fa..0169c3a 100644
--- a/test/links.c
+++ b/test/links.c
@@ -27,6 +27,8 @@ const char *FILENAME[] = {
NULL
};
+#define LINK_BUF_SIZE 1024
+#define NAME_BUF_SIZE 1024
#define MAX_NAME_LEN ((64*1024)+1024)
@@ -51,7 +53,7 @@ mklinks(hid_t fapl)
{
hid_t file, scalar, grp, d1;
hsize_t size[1] = {1};
- char filename[1024];
+ char filename[NAME_BUF_SIZE];
TESTING("link creation");
@@ -122,7 +124,7 @@ new_links(hid_t fapl)
hid_t grp1_a=(-1), grp1_b=(-1), grp2_a=(-1), grp2_b=(-1);
hid_t scalar=(-1);
hid_t dset1=(-1), dset2=(-1);
- char filename[1024];
+ char filename[NAME_BUF_SIZE];
hsize_t size[1] = {1};
TESTING("H5Glink2 function");
@@ -246,8 +248,8 @@ cklinks(hid_t fapl)
{
hid_t file;
H5G_stat_t sb1, sb2;
- char linkval[1024];
- char filename[1024];
+ char linkval[LINK_BUF_SIZE];
+ char filename[NAME_BUF_SIZE];
herr_t status;
TESTING("link queries");
@@ -289,7 +291,7 @@ cklinks(hid_t fapl)
if (H5Gget_linkval(file, "grp1/soft", sizeof linkval, linkval)<0) {
goto error;
}
- if (strcmp(linkval, "/d1")) {
+ if (HDstrcmp(linkval, "/d1")) {
H5_FAILED();
puts(" Soft link test failed. Wrong link value");
goto error;
@@ -313,7 +315,7 @@ cklinks(hid_t fapl)
if (H5Gget_linkval(file, "grp1/dangle", sizeof linkval, linkval)<0) {
goto error;
}
- if (strcmp(linkval, "foobar")) {
+ if (HDstrcmp(linkval, "foobar")) {
H5_FAILED();
puts(" Dangling link test failed. Wrong link value");
goto error;
@@ -337,7 +339,7 @@ cklinks(hid_t fapl)
if (H5Gget_linkval(file, "grp1/recursive", sizeof linkval, linkval)<0) {
goto error;
}
- if (strcmp(linkval, "/grp1/recursive")) {
+ if (HDstrcmp(linkval, "/grp1/recursive")) {
H5_FAILED();
puts(" Recursive link test failed. Wrong link value");
goto error;
@@ -375,8 +377,8 @@ ck_new_links(hid_t fapl)
{
hid_t file;
H5G_stat_t sb_dset, sb_hard1, sb_hard2, sb_soft1, sb_soft2;
- char filename[1024];
- char linkval[1024];
+ char filename[NAME_BUF_SIZE];
+ char linkval[LINK_BUF_SIZE];
TESTING("new link queries");
@@ -428,7 +430,7 @@ ck_new_links(hid_t fapl)
if (H5Gget_linkval(file, "grp2/soft2", sizeof linkval, linkval)<0) {
goto error;
}
- if (strcmp(linkval, "/grp1/dataset2")) {
+ if (HDstrcmp(linkval, "/grp1/dataset2")) {
H5_FAILED();
puts(" Soft link test failed. Wrong link value");
goto error;
@@ -468,7 +470,7 @@ long_links(hid_t fapl)
hid_t gid2 = (-1); /* Datatype ID */
char *objname = NULL; /* Name of object [Long] */
size_t u; /* Local index variable */
- char filename[1024];
+ char filename[NAME_BUF_SIZE];
TESTING("long names for objects & links");
diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c
index b4a8728..b6e3856 100644
--- a/tools/h5dump/h5dump.c
+++ b/tools/h5dump/h5dump.c
@@ -25,6 +25,23 @@
/* module-scoped variables */
const char *progname = "h5dump";
+/* Macros for displaying objects */
+#define begin_obj(obj,name,begin) \
+ if (name) \
+ printf("%s \"%s\" %s\n", (obj), (name), (begin)); \
+ else \
+ printf("%s %s\n", (obj), (begin));
+
+#define end_obj(obj,end) \
+ if(HDstrlen(end)) { \
+ printf("%s", end); \
+ if(HDstrlen(obj)) \
+ printf(" "); \
+ } \
+ if(HDstrlen(obj)) \
+ printf("%s", obj); \
+ printf("\n");
+
/* 3 private values: can't be set, but can be read.
Note: these are defined in H5Zprivate, they are
duplicated here.
@@ -3542,7 +3559,7 @@ main(int argc, const char *argv[])
goto done;
}
- /* start to dump */
+ /* start to dump - display file header information */
if (!doxml) {
begin_obj(dump_header_format->filebegin, fname,
dump_header_format->fileblockbegin);
@@ -3550,40 +3567,39 @@ main(int argc, const char *argv[])
printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
/* alternative first element, depending on schema or DTD. */
if (useschema) {
- if (strcmp(xmlnsprefix,"") == 0) {
- printf("<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
- xml_dtd_uri);
- } else {
+ if (strcmp(xmlnsprefix,"") == 0) {
+ printf("<HDF5-File xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"%s\">\n",
+ xml_dtd_uri);
+ } else {
/* TO DO: make -url option work in this case (may need new option) */
- char * ns;
- char *indx;
- ns = strdup(xmlnsprefix);
- indx = strrchr(ns,(int)':');
- if (indx) *indx = '\0';
-
- printf("<%sHDF5-File xmlns:%s=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File\" "
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
- "xsi:schemaLocation=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5File "
- "http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns);
- }
+ char * ns;
+ char *indx;
+
+ ns = strdup(xmlnsprefix);
+ indx = strrchr(ns,(int)':');
+ if (indx) *indx = '\0';
+
+ printf("<%sHDF5-File xmlns:%s=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xsi:schemaLocation=\"http://hdf.ncsa.uiuc.edu/DTDs/HDF5File "
+ "http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd\">\n",xmlnsprefix,ns);
+ }
} else {
- printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
- xml_dtd_uri);
- printf("<HDF5-File>\n");
+ printf("<!DOCTYPE HDF5-File PUBLIC \"HDF5-File.dtd\" \"%s\">\n",
+ xml_dtd_uri);
+ printf("<HDF5-File>\n");
}
}
- if (!doxml)
- {
- if (display_fi)
- {
- dump_fcontents(fid);
- end_obj(dump_header_format->fileend,dump_header_format->fileblockend);
- goto done;
- }
+ if (!doxml) {
+ if (display_fi) {
+ dump_fcontents(fid);
+ end_obj(dump_header_format->fileend,dump_header_format->fileblockend);
+ goto done;
+ }
- if (display_bb)
- dump_fcpl(fid);
+ if (display_bb)
+ dump_fcpl(fid);
}
@@ -3866,7 +3882,7 @@ xml_escape_the_name(const char *str)
return HDstrdup(str);
cp = str;
- rcp = ncp = calloc((size_t)(len + extra + 1), sizeof(char));
+ rcp = ncp = HDmalloc(len + extra + 1);
if (!ncp)
return NULL; /* ?? */
@@ -4053,14 +4069,12 @@ xml_print_datatype(hid_t type, unsigned in_group)
/* 'anonymous' NDT. Use it's object num.
as it's name. */
printf("<%sNamedDataTypePtr OBJ-XID=\"/%s\"/>\n",
- xmlnsprefix,
- dtxid);
+ xmlnsprefix, dtxid);
} else {
/* point to the NDT by name */
char *t_objname = xml_escape_the_name(type_table->objs[ret].objname);
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\"/>\n",
- xmlnsprefix,
- dtxid,t_objname);
+ xmlnsprefix, dtxid,t_objname);
free(t_objname);
}
free(dtxid);
@@ -4423,15 +4437,13 @@ xml_dump_datatype(hid_t type)
use it's object ref as its name
*/
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\"/>\n",
- xmlnsprefix,
- dtxid);
+ xmlnsprefix, dtxid);
} else {
/* pointer to a named data type already in XML */
char *t_objname = xml_escape_the_name(type_table->objs[i].objname);
printf("<%sNamedDataTypePtr OBJ-XID=\"%s\" H5Path=\"%s\" />\n",
- xmlnsprefix,
- dtxid,t_objname);
+ xmlnsprefix, dtxid,t_objname);
free(t_objname);
}
free(dtxid);
@@ -5081,7 +5093,6 @@ xml_print_refs(hid_t did, int source)
hid_t type, space;
char *buf;
hobj_ref_t *refbuf;
- char *path;
hsize_t ssiz;
hsize_t i;
@@ -5139,6 +5150,8 @@ xml_print_refs(hid_t did, int source)
ssiz = H5Sget_simple_extent_npoints(space);
for (i = 0; i < ssiz; i++) {
+ const char *path;
+
path = lookup_ref_path(*refbuf);
indentation(indent + COL);
@@ -5419,7 +5432,8 @@ check_filters(hid_t dcpl)
}
}
-static void xml_dump_fill_value(hid_t dcpl, hid_t type)
+static void
+xml_dump_fill_value(hid_t dcpl, hid_t type)
{
size_t sz;
size_t i;
@@ -5533,11 +5547,11 @@ char * name;
break;
}
}
- free(buf);
- indent -= COL;
- indentation(indent);
- printf("</%sData>\n",xmlnsprefix);
- indent -= COL;
+ free(buf);
+ indent -= COL;
+ indentation(indent);
+ printf("</%sData>\n",xmlnsprefix);
+ indent -= COL;
}
/*-------------------------------------------------------------------------
* Function: xml_dump_group
diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h
index ba1eab2..96e7d71 100644
--- a/tools/h5dump/h5dump.h
+++ b/tools/h5dump/h5dump.h
@@ -18,19 +18,4 @@
#define H5DUMP_MAX_RANK H5S_MAX_RANK
-#define begin_obj(obj,name,begin) \
- if (name) \
- printf("%s \"%s\" %s\n", (obj), (name), (begin)); \
- else \
- printf("%s %s\n", (obj), (begin));
-
-#define end_obj(obj,end) \
- if(HDstrlen(end)) \
- printf("%s", end); \
- if(HDstrlen(end) && HDstrlen(obj)) \
- printf(" "); \
- if(HDstrlen(obj)) \
- printf("%s", obj); \
- printf("\n");
-
#endif /* !H5DUMP_H__ */
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index 7957383..cd2de6f 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -154,16 +154,15 @@ sym_insert(H5G_stat_t *sb, const char *name)
/* Extend the table */
if (idtab_g.nobjs>=idtab_g.nalloc) {
- idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc);
- idtab_g.obj = realloc(idtab_g.obj,
- idtab_g.nalloc*sizeof(idtab_g.obj[0]));
+ idtab_g.nalloc = MAX(256, 2*idtab_g.nalloc);
+ idtab_g.obj = realloc(idtab_g.obj,
+ idtab_g.nalloc*sizeof(idtab_g.obj[0]));
}
/* Insert the entry */
n = idtab_g.nobjs++;
idtab_g.obj[n].id = sb->objno;
- idtab_g.obj[n].name = malloc(strlen(name)+1);
- strcpy(idtab_g.obj[n].name, name);
+ idtab_g.obj[n].name = HDstrdup(name);
}
@@ -190,8 +189,8 @@ sym_lookup(H5G_stat_t *sb)
if (sb->nlink<2) return NULL; /*only one name possible*/
for (n=0; n<idtab_g.nobjs; n++) {
- if (idtab_g.obj[n].id==sb->objno)
- return idtab_g.obj[n].name;
+ if (idtab_g.obj[n].id==sb->objno)
+ return idtab_g.obj[n].name;
}
return NULL;
}
@@ -219,56 +218,56 @@ display_string(FILE *stream, const char *s, hbool_t escape_spaces)
int nprint=0;
for (/*void*/; s && *s; s++) {
- switch (*s) {
- case '"':
- if (stream) fprintf(stream, "\\\"");
- nprint += 2;
- break;
- case '\\':
- if (stream) fprintf(stream, "\\\\");
- nprint += 2;
- break;
- case '\b':
- if (stream) fprintf(stream, "\\b");
- nprint += 2;
- break;
- case '\f':
- if (stream) fprintf(stream, "\\f");
- nprint += 2;
- break;
- case '\n':
- if (stream) fprintf(stream, "\\n");
- nprint += 2;
- break;
- case '\r':
- if (stream) fprintf(stream, "\\r");
- nprint += 2;
- break;
- case '\t':
- if (stream) fprintf(stream, "\\t");
- nprint += 2;
- break;
- case ' ':
- if (escape_spaces) {
- if (stream) fprintf(stream, "\\ ");
- nprint += 2;
- } else {
- if (stream) fprintf(stream, " ");
- nprint++;
- }
- break;
- default:
- if (isprint((int)*s)) {
- if (stream) putc(*s, stream);
- nprint++;
- } else {
- if (stream) {
- fprintf(stream, "\\%03o", *((const unsigned char*)s));
- }
- nprint += 4;
- }
- break;
- }
+ switch (*s) {
+ case '"':
+ if (stream) fprintf(stream, "\\\"");
+ nprint += 2;
+ break;
+ case '\\':
+ if (stream) fprintf(stream, "\\\\");
+ nprint += 2;
+ break;
+ case '\b':
+ if (stream) fprintf(stream, "\\b");
+ nprint += 2;
+ break;
+ case '\f':
+ if (stream) fprintf(stream, "\\f");
+ nprint += 2;
+ break;
+ case '\n':
+ if (stream) fprintf(stream, "\\n");
+ nprint += 2;
+ break;
+ case '\r':
+ if (stream) fprintf(stream, "\\r");
+ nprint += 2;
+ break;
+ case '\t':
+ if (stream) fprintf(stream, "\\t");
+ nprint += 2;
+ break;
+ case ' ':
+ if (escape_spaces) {
+ if (stream) fprintf(stream, "\\ ");
+ nprint += 2;
+ } else {
+ if (stream) fprintf(stream, " ");
+ nprint++;
+ }
+ break;
+ default:
+ if (isprint((int)*s)) {
+ if (stream) putc(*s, stream);
+ nprint++;
+ } else {
+ if (stream) {
+ fprintf(stream, "\\%03o", *((const unsigned char*)s));
+ }
+ nprint += 4;
+ }
+ break;
+ }
}
return nprint;
}
@@ -1670,8 +1669,8 @@ group_list2(hid_t grp, const char *name)
iter_t iter;
if (recursive_g) {
- iter.container = name;
- H5Giterate(grp, ".", NULL, list, &iter);
+ iter.container = name;
+ H5Giterate(grp, ".", NULL, list, &iter);
}
return 0;
}
@@ -1773,51 +1772,51 @@ list (hid_t group, const char *name, void *_iter)
/* Print the object name, either full name or base name */
fullname = fix_name(iter->container, name);
if (fullname_g) {
- n = display_string(stdout, fullname, TRUE);
- printf("%*s ", MAX(0, 24-n), "");
+ n = display_string(stdout, fullname, TRUE);
+ printf("%*s ", MAX(0, 24-n), "");
} else {
- n = display_string(stdout, name, TRUE);
- printf("%*s ", MAX(0, 24-n), "");
+ n = display_string(stdout, name, TRUE);
+ printf("%*s ", MAX(0, 24-n), "");
}
/* Get object information */
H5E_BEGIN_TRY {
- status = H5Gget_objinfo(group, name, FALSE, &sb);
+ status = H5Gget_objinfo(group, name, FALSE, &sb);
} H5E_END_TRY;
if (status<0) {
- puts("**NOT FOUND**");
- return 0;
+ puts("**NOT FOUND**");
+ return 0;
} else if (sb.type<0 || sb.type>=H5G_NTYPES) {
- printf("Unknown type(%d)", sb.type);
- sb.type = H5G_UNKNOWN;
+ printf("Unknown type(%d)", sb.type);
+ sb.type = H5G_UNKNOWN;
}
if (sb.type>=0 && dispatch_g[sb.type].name) {
- fputs(dispatch_g[sb.type].name, stdout);
+ fputs(dispatch_g[sb.type].name, stdout);
}
/* If the object has already been printed then just show the object ID
* and return. */
if ((s=sym_lookup(&sb))) {
- printf(", same as ");
- display_string(stdout, s, TRUE);
- printf("\n");
- goto done;
+ printf(", same as ");
+ display_string(stdout, s, TRUE);
+ printf("\n");
+ goto done;
} else {
- sym_insert(&sb, fullname);
+ sym_insert(&sb, fullname);
}
/* Open the object. Not all objects can be opened. If this is the case
* then return right away. */
if (sb.type>=0 &&
- (NULL==dispatch_g[sb.type].open ||
- (obj=(dispatch_g[sb.type].open)(group, name))<0)) {
- printf(" *ERROR*\n");
- goto done;
+ (NULL==dispatch_g[sb.type].open ||
+ (obj=(dispatch_g[sb.type].open)(group, name))<0)) {
+ printf(" *ERROR*\n");
+ goto done;
}
/* List the first line of information for the object. */
if (sb.type>=0 && dispatch_g[sb.type].list1) {
- (dispatch_g[sb.type].list1)(obj);
+ (dispatch_g[sb.type].list1)(obj);
}
putchar('\n');
@@ -1832,27 +1831,27 @@ list (hid_t group, const char *name, void *_iter)
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);
- printf(" %-10s %s\n", "Modified:", buf);
- }
- }
- comment[0] = '\0';
- H5Gget_comment(group, name, sizeof(comment), comment);
- strcpy(comment+sizeof(comment)-4, "...");
- if (comment[0]) {
- printf(" %-10s \"", "Comment:");
- display_string(stdout, comment, FALSE);
- puts("\"");
- }
+ strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
+ printf(" %-10s %s\n", "Modified:", buf);
+ }
+ }
+ comment[0] = '\0';
+ H5Gget_comment(group, name, sizeof(comment), comment);
+ strcpy(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) {
- (dispatch_g[sb.type].list2)(obj, fullname);
+ (dispatch_g[sb.type].list2)(obj, fullname);
}
/* Close the object. */
- done:
+done:
if (sb.type>=0 && obj>=0 && dispatch_g[sb.type].close) {
- (dispatch_g[sb.type].close)(obj);
+ (dispatch_g[sb.type].close)(obj);
}
if (fullname) free(fullname);
return 0;
@@ -1880,25 +1879,28 @@ list (hid_t group, const char *name, void *_iter)
static char *
fix_name(const char *path, const char *base)
{
- size_t n = (path?strlen(path):0) + (base?strlen(base):0) + 3;
- char *s = malloc(n), prev='\0';
- int len=0;
+ size_t n = (path ? HDstrlen(path) : 0) + (base ? HDstrlen(base) : 0) + 3;
+ char *s = HDmalloc(n), prev='\0';
+ size_t len = 0;
if (path) {
- /* Path, followed by slash */
- for (/*void*/; *path; path++) {
- if ('/'!=*path || '/'!=prev) prev = s[len++] = *path;
- }
- if ('/'!=prev) prev = s[len++] = '/';
+ /* Path, followed by slash */
+ for (/*void*/; *path; path++)
+ if ('/'!=*path || '/'!=prev)
+ prev = s[len++] = *path;
+ if ('/' != prev)
+ prev = s[len++] = '/';
}
if (base) {
- /* Base name w/o trailing slashes */
- const char *end = base + strlen(base);
- while (end>base && '/'==end[-1]) --end;
- for (/*void*/; base<end; base++) {
- if ('/'!=*base || '/'!=prev) prev = s[len++] = *base;
- }
+ /* Base name w/o trailing slashes */
+ const char *end = base + HDstrlen(base);
+ while (end > base && '/' == end[-1])
+ --end;
+
+ for (/*void*/; base < end; base++)
+ if ('/' != *base || '/' != prev)
+ prev = s[len++] = *base;
}
s[len] = '\0';