summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2002-08-28 18:34:12 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2002-08-28 18:34:12 (GMT)
commit7bff4eb559d3f28f27ab29ced0d1e46ada1df620 (patch)
tree26415f62114ac52c107ef88cacfb58218facbefa /src
parentfc5e3b4897f695b2d61518954047cc783c8baa1d (diff)
downloadhdf5-7bff4eb559d3f28f27ab29ced0d1e46ada1df620.zip
hdf5-7bff4eb559d3f28f27ab29ced0d1e46ada1df620.tar.gz
hdf5-7bff4eb559d3f28f27ab29ced0d1e46ada1df620.tar.bz2
[svn-r5904]
Purpose: Added 'ID to name' support Description: There is a new API function H5Iget_name Most of the changes are on H5G.c , regarding the symbol table entry struct H5G_entry_t which has 2 new fields 'name' and 'old_name' A new private function was introduced H5G_ent_copy, that does a deep copy between 2 symbol table entries The test file is getname.c Platforms tested: windows 2000, Linux, Solaris
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c19
-rw-r--r--src/H5D.c9
-rw-r--r--src/H5F.c24
-rw-r--r--src/H5G.c664
-rw-r--r--src/H5Gent.c46
-rw-r--r--src/H5Gprivate.h30
-rw-r--r--src/H5Gstab.c41
-rw-r--r--src/H5I.c385
-rw-r--r--src/H5Ipublic.h4
-rw-r--r--src/H5O.c10
-rw-r--r--src/H5Odtype.c12
-rw-r--r--src/H5T.c10
12 files changed, 1187 insertions, 67 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 678f37e..6703a6f 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -201,6 +201,10 @@ done:
* April 2, 1998
*
* Modifications:
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
static hid_t
@@ -240,8 +244,9 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
/* Mark it initially set to initialized */
attr->initialized = TRUE; /*for now, set to false later*/
- /* Copy the symbol table entry */
- attr->ent=*ent;
+ /* Deep copy of the symbol table entry */
+ if (H5G_ent_copy(ent,&(attr->ent))<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
/* Compute the internal sizes */
attr->dt_size=(H5O_DTYPE[0].raw_size)(attr->ent.file,type);
@@ -472,6 +477,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
static hid_t
@@ -490,9 +498,10 @@ H5A_open(H5G_entry_t *ent, unsigned idx)
if (NULL==(attr=H5O_read(ent, H5O_ATTR, (int)idx, attr)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from dataset header");
attr->initialized=1;
-
- /* Copy the symbol table entry */
- attr->ent=*ent;
+
+ /* Deep copy of the symbol table entry */
+ if (H5G_ent_copy(ent,&(attr->ent))<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
/* Hold the symbol table entry (and file) open */
if (H5O_open(&(attr->ent)) < 0) {
diff --git a/src/H5D.c b/src/H5D.c
index 577e25f..a15f00d 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1958,6 +1958,9 @@ done:
* Feb 26, 2002
* A new fill value message and two new properties are added.
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
H5D_t *
@@ -1982,8 +1985,10 @@ H5D_open_oid(H5G_entry_t *ent)
if(NULL==(dataset = H5D_new(H5P_DEFAULT)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- /* Copy over the symbol table information if it's provided */
- HDmemcpy(&(dataset->ent),ent,sizeof(H5G_entry_t));
+ /* Deep copy of the symbol table entry */
+ if (H5G_ent_copy(ent,&(dataset->ent))<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to copy entry");
+
/* Find the dataset object */
if (H5O_open(&(dataset->ent)) < 0)
diff --git a/src/H5F.c b/src/H5F.c
index 564fefc..13421a1 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -2912,9 +2912,12 @@ done:
*
* Modifications:
*
- * Robb Matzke, 1998-10-14
+ * Robb Matzke, 1998-10-14
* The ref count for the child is decremented by calling H5F_close().
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -2954,6 +2957,11 @@ H5F_unmount(H5G_entry_t *loc, const char *name)
parent = child->mtab.parent;
for (i=0; i<parent->mtab.nmounts; i++) {
if (parent->mtab.child[i].file==child) {
+
+ /* Search the symbol table entry list and replace names through group IDs */
+ if (H5G_replace_name( H5G_UNKNOWN, loc, name, NULL, OP_UNMOUNT )<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ");
+
/* Unmount the child */
parent->mtab.nmounts -= 1;
H5G_close(parent->mtab.child[i].group);
@@ -3022,6 +3030,9 @@ done:
* Tuesday, October 6, 1998
*
* Modifications:
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
*
*-------------------------------------------------------------------------
*/
@@ -3032,6 +3043,7 @@ H5F_mountpoint(H5G_entry_t *find/*in,out*/)
int lt, rt, md=(-1), cmp;
H5G_entry_t *ent = NULL;
herr_t ret_value=SUCCEED; /* Return value */
+ char *tmp;
FUNC_ENTER_NOAPI(H5F_mountpoint, FAIL);
@@ -3063,7 +3075,9 @@ H5F_mountpoint(H5G_entry_t *find/*in,out*/)
/* Copy root info over to ENT */
if (0==cmp) {
ent = H5G_entof(parent->mtab.child[md].file->shared->root_grp);
+ tmp = find->name;
*find = *ent;
+ find->name = tmp;
parent = ent->file;
}
} while (!cmp);
@@ -3086,6 +3100,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -3114,6 +3131,11 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id)
if (H5F_mount(loc, name, child, plist_id)<0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file");
+ /* Search the symbol table entry list and replace names through group IDs */
+ /* We pass H5G_UNKNOWN as object type; search all IDs */
+ if (H5G_replace_name( H5G_UNKNOWN, loc, name, NULL, OP_MOUNT )<0)
+ HRETURN_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name ");
+
done:
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5G.c b/src/H5G.c
index d12f5e3..2141389 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -69,6 +69,9 @@
* Robb Matzke, 30 Aug 1997
* Added `Errors:' field to function prologues.
*
+ * Pedro Vicente, 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
@@ -107,6 +110,10 @@ static size_t H5G_comp_alloc_g = 0; /*sizeof component buffer */
/* Declare a free list to manage the H5G_t struct */
H5FL_DEFINE(H5G_t);
+/* Private prototypes */
+static herr_t H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key);
+
+
/*-------------------------------------------------------------------------
* Function: H5Gcreate
@@ -489,6 +496,9 @@ done:
* Monday, April 6, 1998
*
* Modifications:
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
*
*-------------------------------------------------------------------------
*/
@@ -497,6 +507,7 @@ H5Gunlink(hid_t loc_id, const char *name)
{
H5G_entry_t *loc = NULL;
herr_t ret_value=SUCCEED; /* Return value */
+ H5G_stat_t statbuf;
FUNC_ENTER_API(H5Gunlink, FAIL);
H5TRACE2("e","is",loc_id,name);
@@ -507,10 +518,19 @@ H5Gunlink(hid_t loc_id, const char *name)
if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ /* Get object type before unlink */
+ if (H5G_get_objinfo(loc, name, FALSE, &statbuf)<0) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
+ }
+
/* Unlink */
if (H5G_unlink(loc, name)<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink object");
+ /* Search the symbol table entry list and replace names through group IDs */
+ if (H5G_replace_name( statbuf.type, loc, name, NULL, OP_UNLINK )<0)
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ");
+
done:
FUNC_LEAVE (ret_value);
}
@@ -1025,6 +1045,10 @@ H5G_basename(const char *name, size_t *size_p)
* called.
* (2) We need to be able to free it from H5G_term_interface()
* when the library terminates.
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1038,6 +1062,8 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
int _nlinks = H5G_NLINKS;
const char *s = NULL;
herr_t ret_value=SUCCEED; /* Return value */
+
+ H5G_t *tmp_grp;
FUNC_ENTER_NOINIT(H5G_namei);
@@ -1055,10 +1081,18 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
} else if (!loc_ent) {
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group");
} else if ('/' == *name) {
- *obj_ent = H5G_rootof(loc_ent->file)->ent;
+ tmp_grp=H5G_rootof(loc_ent->file);
+
+ /* Deep copy of the symbol table entry */
+ if (H5G_ent_copy( &(tmp_grp->ent), obj_ent )<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
+
} else {
- *obj_ent = *loc_ent;
+ /* Deep copy of the symbol table entry */
+ if (H5G_ent_copy( loc_ent, obj_ent )<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;
@@ -1156,6 +1190,9 @@ done:
* Friday, April 10, 1998
*
* Modifications:
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
*
*-------------------------------------------------------------------------
*/
@@ -1168,6 +1205,9 @@ H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
const char *clv = NULL; /*cached link value */
char *linkval = NULL; /*the copied link value */
herr_t ret_value=SUCCEED; /* Return value */
+
+ /*Store old name */
+ char* old_name=obj_ent->name;
FUNC_ENTER_NOAPI(H5G_traverse_slink, FAIL);
@@ -1183,6 +1223,8 @@ H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
if (H5G_namei (grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks))
HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link");
+ obj_ent->name = old_name;
+
done:
H5MM_xfree (linkval);
FUNC_LEAVE (ret_value);
@@ -1207,6 +1249,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -1246,6 +1291,11 @@ H5G_mkroot (H5F_t *f, H5G_entry_t *ent)
H5O_reset (H5O_STAB, &stab);
}
+ /*create the "/" name */
+ ent->name = HDstrdup( "/" );
+ ent->old_name = NULL;
+
+
/*
* Create the group pointer. Also decrement the open object count so we
* don't count the root group as an open object. The root group will
@@ -1453,6 +1503,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
H5G_t *
@@ -1471,8 +1524,9 @@ H5G_open_oid(H5G_entry_t *ent)
if (NULL==(grp = H5FL_ALLOC(H5G_t,1)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- /* Copy over the symbol table information if it's provided */
- HDmemcpy(&(grp->ent),ent,sizeof(H5G_entry_t));
+ /*deep copy of the symbol table entry*/
+ if (H5G_ent_copy(ent,&(grp->ent))<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to copy entry");
/* Grab the object header */
if (H5O_open(&(grp->ent)) < 0)
@@ -2314,8 +2368,11 @@ done:
*
* Modifications:
*
- * Raymond Lu
- * Thursday, April 18, 2002
+ * Raymond Lu
+ * Thursday, April 18, 2002
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
*
*-------------------------------------------------------------------------
*/
@@ -2366,6 +2423,14 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc,
if (H5G_unlink(src_loc, src_name)<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to deregister old object name");
+ /*
+ Search the symbol table entry list and replace names through group IDs
+ This has to be done here because H5G_link and H5G_unlink have
+ internal object entries , and do not modify the entries list
+ */
+ if (H5G_replace_name( sb.type, src_loc, src_name, dst_name, OP_MOVE )<0)
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ");
+
done:
FUNC_LEAVE(ret_value);
}
@@ -2422,3 +2487,590 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name)
done:
FUNC_LEAVE(ret_value);
}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_insert_name
+ *
+ * Purpose: Insert a name into the symbol entry OBJ, located at LOC
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: August 22, 2002
+ *
+ * Comments: The allocated memory (H5MM_malloc) is freed in H5O_close
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5G_insert_name(H5G_entry_t *loc, H5G_entry_t *obj, const char *name)
+{
+
+ size_t len1, len2;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5G_insert_name, FAIL);
+
+ if ( loc->name ) {
+
+ len1 = HDstrlen(loc->name);
+ len2 = HDstrlen(name);
+ assert(len2>0&&len1>0);
+ /* this is the root group */
+ if ('/'==loc->name[len1-1])
+ {
+
+ if (NULL==(obj->name = H5MM_malloc (len1+len2+1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HDstrcpy(obj->name, loc->name);
+ HDstrcpy(obj->name+len1, name);
+
+ }
+ /* this is a subgroup */
+ else
+ {
+ if (NULL==(obj->name = H5MM_malloc (len1+1+len2+1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HDstrcpy(obj->name, loc->name);
+ HDstrcpy(obj->name+len1, "/");
+ HDstrcpy(obj->name+len1+1, name);
+ }
+ }
+
+done:
+ FUNC_LEAVE(ret_value);
+
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_replace_name
+ *
+ * Purpose: Search the symbol table entry list and replace names through group IDs
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: June 11, 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t H5G_replace_name( int type, H5G_entry_t *loc, const char *src_name,
+ const char *dst_name, int op )
+{
+
+ H5G_names_t names;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5G_replace_name, FAIL);
+
+ names.src_name=src_name;
+ names.dst_name=dst_name;
+ names.loc=loc;
+ names.op=op;
+
+ switch ( type )
+ {
+
+ /* Object is a group */
+ case H5G_GROUP:
+
+ /* Search and replace names through group IDs */
+ names.obj_type = H5I_GROUP;
+ H5I_search(H5I_GROUP, (H5I_search_func_t)H5G_replace_ent, &names );
+
+ break;
+
+ /* Object is a dataset */
+ case H5G_DATASET:
+
+ /* Search and replace names through dataset IDs */
+ names.obj_type = H5I_DATASET;
+ H5I_search(H5I_DATASET, (H5I_search_func_t)H5G_replace_ent, &names );
+
+ break;
+
+ /* Object is a named data type */
+ case H5G_TYPE:
+
+ /* Search and replace names through datatype IDs */
+ names.obj_type = H5I_DATATYPE;
+ H5I_search(H5I_DATATYPE, (H5I_search_func_t)H5G_replace_ent, &names );
+
+ break;
+
+ /* We pass H5G_UNKNOWN as object type for the H5Fmount case; search all IDs */
+ case H5G_UNKNOWN:
+
+ /* Search through group IDs */
+ if ( H5I_nmembers(H5I_GROUP) ) {
+ names.obj_type = H5I_GROUP;
+ H5I_search(H5I_GROUP, (H5I_search_func_t)H5G_replace_ent, &names );
+ }
+ /* Search through dataset IDs */
+ if ( H5I_nmembers(H5I_DATASET) ) {
+ names.obj_type = H5I_DATASET;
+ H5I_search(H5I_DATASET, (H5I_search_func_t)H5G_replace_ent, &names );
+ }
+ /* Search through datatype IDs */
+ if ( H5I_nmembers(H5I_DATATYPE) ) {
+ names.obj_type = H5I_DATATYPE;
+ H5I_search(H5I_DATATYPE, (H5I_search_func_t)H5G_replace_ent, &names );
+ }
+
+ break;
+
+ /* Object is a symbolic link */
+
+ case H5G_LINK:
+
+ /* Search through group IDs */
+ if ( H5I_nmembers(H5I_GROUP) ) {
+ names.obj_type = H5I_GROUP;
+ H5I_search(H5I_GROUP, (H5I_search_func_t)H5G_replace_ent, &names );
+ }
+ /* Search through dataset IDs */
+ if ( H5I_nmembers(H5I_DATASET) ) {
+ names.obj_type = H5I_DATASET;
+ H5I_search(H5I_DATASET, (H5I_search_func_t)H5G_replace_ent, &names );
+ }
+ /* Search through datatype IDs */
+ if ( H5I_nmembers(H5I_DATATYPE) ) {
+ names.obj_type = H5I_DATATYPE;
+ H5I_search(H5I_DATATYPE, (H5I_search_func_t)H5G_replace_ent, &names );
+ }
+
+ break;
+
+ default:
+ HRETURN_ERROR (H5E_DATATYPE, H5E_BADTYPE, FAIL,
+ "not valid object type");
+
+ };
+
+done:
+ FUNC_LEAVE( SUCCEED );
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_rest
+ *
+ * Purpose: Get the last component of the name
+ *
+ * Return: SUCCEED
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: July 5, 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+ static herr_t
+ H5G_rest( const char *name, const char **rest/*out*/ )
+ {
+
+ size_t nchars;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI(H5G_rest, FAIL);
+
+ /* traverse the name */
+ while ((name = H5G_component(name, &nchars)) && *name)
+ {
+ if (rest) *rest = name;
+
+ /* next component */
+ name += nchars;
+ }
+
+
+done:
+ FUNC_LEAVE(SUCCEED);
+
+ }
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_replace_ent
+ *
+ * Purpose: H5I_search callback function to replace group entry names
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: June 5, 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+ static herr_t
+ H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key)
+ {
+ H5G_names_t *names = key;
+ H5G_entry_t *ent = NULL;
+ size_t len1, len2;
+ char *tmp_buf;
+ H5F_t *parent_file;
+ H5F_t *child_file;
+ H5F_mount_t *child_mnt;
+ H5G_entry_t *child_grp_ent;
+ unsigned i;
+ size_t len;
+ const char *rest = NULL; /*the base name */
+ int cmp;
+ char *new_src_name;
+ char *new_dst_name;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(H5G_replace_ent, FAIL);
+
+ assert(obj_ptr);
+
+ /* avoid no named datatypes */
+ if( names->obj_type==H5I_DATATYPE && H5T_is_immutable((H5T_t*)obj_ptr))
+ {
+ /* Do not exit loop */
+ ret_value = SUCCEED;
+ goto done;
+ }
+
+ /* Get the symbol table entry */
+ switch(names->obj_type) {
+ case H5I_GROUP:
+ ent = H5G_entof((H5G_t*)obj_ptr);
+ break;
+ case H5I_DATASET:
+ ent = H5D_entof((H5D_t*)obj_ptr);
+ break;
+ case H5I_DATATYPE:
+ ent = H5T_entof((H5T_t*)obj_ptr);
+ break;
+ default:
+ ret_value = FAIL;
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "unknown data object");
+ }
+
+
+ /* Check if is a mounted file */
+ if(ent->file->mtab.parent) {
+
+ if(ent->file->mtab.parent->shared != names->loc->file->shared )
+ {
+ /* Do not exit loop */
+ ret_value = SUCCEED;
+ goto done;
+ }
+
+
+ if ( names->op==OP_UNLINK || names->op==OP_MOVE ) {
+ parent_file = ent->file->mtab.parent;
+ for ( i = 0; i < parent_file->mtab.nmounts; i++ )
+ {
+ child_mnt = &parent_file->mtab.child[i];
+ child_file = child_mnt->file;
+
+ /* we found the right file */
+ if( ent->file->shared == child_file->shared )
+ {
+ child_grp_ent = &child_mnt->group->ent;
+ len = HDstrlen( child_grp_ent->name );
+
+ /* Find the prefix of the name */
+ cmp = HDstrncmp( child_grp_ent->name, names->src_name, len);
+ if ( cmp == 0 )
+ {
+ new_src_name=H5MM_strdup(names->src_name+len);
+
+ if (names->op==OP_UNLINK)
+ new_dst_name=H5MM_strdup(names->dst_name);
+ else if (names->op==OP_MOVE)
+ new_dst_name=H5MM_strdup(names->dst_name+len);
+
+ /* Search the symbol table entry list and replace names through group IDs */
+ if (H5G_replace_name( H5G_UNKNOWN,
+ child_grp_ent,
+ new_src_name,
+ new_dst_name,
+ names->op )<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ");
+
+ H5MM_xfree(new_dst_name);
+
+
+ }/*if */
+
+ }/*if */
+
+
+ } /*for */
+ }/*if */
+
+
+ } /*if */
+
+ /* Verify if file IDs refer to the same file */
+ else {
+ if( ent->file->shared != names->loc->file->shared )
+ {
+ /* Do not exit loop */
+ ret_value = SUCCEED;
+ goto done;
+ }
+ }
+
+ /* Get the type of call we are doing */
+ switch(names->op) {
+
+ /*-------------------------------------------------------------------------
+ * OP_MOUNT
+ *-------------------------------------------------------------------------
+ */
+
+ case OP_MOUNT:
+
+ /* Find entries that might contain part of this name */
+ if ( HDstrstr( ent->name, names->src_name ))
+ {
+
+ /* Store the old name for unmount case */
+ /*ent->old_name = ent->name;*/
+ ent->old_name = HDstrdup(ent->name);
+
+ if (names->dst_name) {
+ len1 = HDstrlen( names->dst_name );
+ ent->name = H5MM_malloc( len1+1 );
+ HDstrcpy( ent->name, names->dst_name );
+ }
+ else
+ HDstrcpy( ent->name, "" );
+
+ }
+
+ /* Do not exit loop */
+ ret_value = 0;
+ goto done;
+ break;
+
+ /*-------------------------------------------------------------------------
+ * OP_UNMOUNT
+ *-------------------------------------------------------------------------
+ */
+
+ case OP_UNMOUNT:
+
+ if(ent->name){
+ /* Find entries that might contain part of this name */
+ if ( HDstrstr( ent->name, names->src_name ))
+ {
+
+ /* Delete the old name */
+ ent->name=H5MM_xfree(ent->name);
+
+ if (names->dst_name){
+ len1 = HDstrlen( names->dst_name );
+ ent->name = H5MM_malloc( len1+1 );
+ HDstrcpy( ent->name, names->dst_name );
+ }
+ }
+ }/*if*/
+
+
+ /* See if the entry old name matches */
+ if ( ent->old_name ) {
+ if ( HDstrstr( ent->old_name, names->src_name ))
+ {
+
+ /* Delete the old name */
+ if (ent->name )
+ H5MM_xfree(ent->name);
+
+ /* Copy the old name to the entry */
+ ent->name = ent->old_name;
+ ent->old_name = NULL;
+ }
+ }
+
+
+ /* Do not exit loop */
+ ret_value = 0;
+
+
+ goto done;
+ break;
+
+ /*-------------------------------------------------------------------------
+ * OP_UNLINK
+ *-------------------------------------------------------------------------
+ */
+
+ case OP_UNLINK:
+
+ /* H5Gunlink case */
+
+ if (ent->name ){
+ cmp = HDstrcmp( ent->name, names->src_name );
+
+ /* Found the correct entry, just replace the name */
+ if ( cmp==0 )
+ {
+ ent->name=H5MM_xfree(ent->name);
+
+ if (names->dst_name){
+ len1 = HDstrlen( names->dst_name );
+ ent->name = H5MM_malloc( len1+1 );
+ HDstrcpy( ent->name, names->dst_name );
+ }
+
+ }
+
+ /* Find other entries that might contain part of this name */
+ else if ( cmp>0 )
+ {
+
+ if ( HDstrstr( ent->name, names->src_name ))
+ {
+ /* Delete the old name and clear the entry */
+ H5MM_xfree(ent->name);
+ ent->name=NULL;
+ }
+
+ }
+ }/*if*/
+
+
+ /* Do not exit loop */
+ ret_value = 0;
+ goto done;
+ break;
+
+ /*-------------------------------------------------------------------------
+ * OP_MOVE
+ *-------------------------------------------------------------------------
+ */
+
+ case OP_MOVE:
+
+ /* H5Gmove case, check for relative names case */
+
+ /* Verify if we have the wanted entry */
+ if ( HDstrcmp( ent->name, names->src_name )!=0 )
+ {
+
+ /* Do not exit loop */
+ ret_value = SUCCEED;
+
+ /* Get the last component of the name */
+ H5G_rest( ent->name, &rest );
+
+ /* Relative names case, build the full pathname */
+ if ( rest && HDstrcmp( rest, names->src_name )==0 )
+ {
+
+ len1 = HDstrlen(ent->name);
+ len2 = HDstrlen(rest);
+ ent->name[len1-len2-1] = '\0';
+
+ tmp_buf = HDstrdup(ent->name);
+
+ len1 = HDstrlen(ent->name);
+ len2 = HDstrlen(names->dst_name);
+ assert(len1>0 && len2>0);
+
+ H5MM_xfree(ent->name);
+ ent->name = H5MM_malloc(len1+1+len2+1);
+ HDstrcpy(ent->name, tmp_buf);
+ HDstrcpy(ent->name+len1, "/");
+ HDstrcpy(ent->name+len1+1, names->dst_name);
+
+ HDfree(tmp_buf);
+
+ /* Found entry, exit loop */
+ ret_value = 1;
+
+ } /* Relative names case */
+
+ goto done;
+
+ } /* wanted entry */
+
+
+ break;
+
+ /*-------------------------------------------------------------------------
+ * OP_LINK
+ *-------------------------------------------------------------------------
+ */
+
+ case OP_LINK:
+
+ /* H5Glink case */
+ cmp = HDstrcmp( ent->name, names->src_name );
+
+ /* Found the correct entry, just replace the name */
+ if ( cmp==0 )
+ {
+
+ if (ent->name )
+ H5MM_xfree(ent->name);
+
+ len1 = HDstrlen( names->dst_name );
+ ent->name = H5MM_malloc( len1+1 );
+ HDstrcpy( ent->name, names->dst_name );
+ }
+
+
+ /* Do not exit loop */
+ ret_value = 0;
+ goto done;
+ break;
+
+
+
+ default:
+ ret_value = FAIL;
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "invalid call");
+ }
+
+
+
+ /* Delete the old name */
+ if (ent->name )
+ H5MM_xfree(ent->name);
+
+ /* Add the new name */
+ len1 = HDstrlen( names->dst_name );
+ ent->name = H5MM_malloc( len1+1 );
+ HDstrcpy( ent->name, names->dst_name );
+
+ /* Found entry, exit loop */
+ ret_value = 1;
+
+done:
+ FUNC_LEAVE(ret_value);
+}
+
diff --git a/src/H5Gent.c b/src/H5Gent.c
index bcc40d8..30c082e 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -337,6 +337,52 @@ done:
FUNC_LEAVE(ret_value);
}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_ent_copy
+ *
+ * Purpose: Do a deep copy of symbol table entries
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: August 2002
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+herr_t
+H5G_ent_copy( const H5G_entry_t *src, H5G_entry_t *dst )
+{
+
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_ent_copy, FAIL);
+
+ assert( src );
+ assert( dst );
+
+ HDmemcpy(dst,src,sizeof(H5G_entry_t));
+
+ if (src->name){
+ dst->name=H5MM_strdup(src->name);
+ }
+ if (src->old_name){
+ dst->old_name=H5MM_strdup(src->old_name);
+ }
+
+
+done:
+ FUNC_LEAVE(SUCCEED);
+}
+
+
/*-------------------------------------------------------------------------
* Function: H5G_ent_debug
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 1d9df9d..7a92c08 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -10,7 +10,10 @@
*
* Purpose: Library-visible declarations.
*
- * Modifications:
+ * Modifications: Aug 22, 2002
+ * Pedro Vicente <pvn@ncsa.uiuc.edu>
+ * Added 'names' field to H5G_entry_t
+ * Added H5G_replace_name
*
*-------------------------------------------------------------------------
*/
@@ -92,6 +95,8 @@ typedef struct H5G_entry_t {
H5G_type_t type; /*type of information cached */
H5G_cache_t cache; /*cached data from object header */
H5F_t *file; /*file to which this obj hdr belongs */
+ char *name; /*name associated with atom */
+ char *old_name; /*old name hidden by a file mount */
} H5G_entry_t;
typedef struct H5G_t H5G_t;
@@ -107,6 +112,25 @@ typedef struct H5G_typeinfo_t {
char *desc; /*description of object type */
} H5G_typeinfo_t;
+
+ typedef enum H5G_names_op_t {
+ OP_MOVE = 0, /* H5*move call */
+ OP_LINK = 1, /* H5Glink call */
+ OP_UNLINK = 2, /* H5Gunlink call */
+ OP_MOUNT = 3, /* H5Fmount call */
+ OP_UNMOUNT= 4 /* H5Funmount call */
+ }H5G_names_op_t;
+
+/* Struct only used by change name callback function */
+typedef struct H5G_names_t {
+ H5I_type_t obj_type;
+ const char *src_name;
+ const char *dst_name;
+ H5G_entry_t *loc;
+ H5G_names_op_t op;
+} H5G_names_t;
+
+
/*
* Library prototypes... These are the ones that other packages routinely
* call.
@@ -168,4 +192,8 @@ __DLL__ H5G_cache_t *H5G_ent_cache(H5G_entry_t *ent, H5G_type_t *cache_type);
__DLL__ herr_t H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type);
__DLL__ herr_t H5G_ent_debug(H5F_t *f, const H5G_entry_t *ent, FILE * stream,
int indent, int fwidth, haddr_t heap);
+__DLL__ herr_t H5G_replace_name( int type, H5G_entry_t *loc, const char *src_name,
+ const char *dst_name, int op );
+__DLL__ herr_t H5G_insert_name( H5G_entry_t *loc, H5G_entry_t *obj, const char *name);
+__DLL__ herr_t H5G_ent_copy( const H5G_entry_t *src, H5G_entry_t *dst );
#endif
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 9c4311c..72c0d25 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -121,6 +121,10 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -131,6 +135,8 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
H5O_stab_t stab; /*symbol table message */
herr_t ret_value=SUCCEED; /* Return value */
+ obj_ent->name=NULL;
+
FUNC_ENTER_NOAPI(H5G_stab_find, FAIL);
/* Check arguments */
@@ -146,10 +152,28 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
udata.heap_addr = stab.heap_addr;
/* search the B-tree */
- if (H5B_find(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
- if (obj_ent)
- *obj_ent = udata.ent;
+ if (H5B_find(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+ }
+
+ /* change OBJ_ENT only if found */
+ else
+ {
+ if (obj_ent) {
+
+ /* do a deep copy */
+ if (H5G_ent_copy( &(udata.ent), obj_ent )<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to copy entry");
+
+ /* insert the name into the symbol entry OBJ_ENT */
+ if (H5G_insert_name( grp_ent, obj_ent, name ) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "cannot insert name");
+ }
+
+ }
+ }
+
done:
FUNC_LEAVE(ret_value);
@@ -173,6 +197,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -207,6 +234,12 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
/* update the name offset in the entry */
obj_ent->name_off = udata.ent.name_off;
+ /* insert the name into the symbol entry OBJ_ENT */
+ if (H5G_insert_name( grp_ent, obj_ent, name ) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "cannot insert name");
+ }
+
done:
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5I.c b/src/H5I.c
index 01d2e20..e86ce66 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -37,6 +37,16 @@
#include "H5FLprivate.h" /*Free Lists */
#include "H5MMprivate.h"
+#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
+#define H5I_DEBUG_OUTPUT
+
+
+#include "H5Gprivate.h" /*symbol tables */
+#include "H5Gpkg.h"
+#include "H5Dprivate.h" /*datasets */
+#include "H5Tprivate.h" /*data types */
+#include "H5Aprivate.h" /*attributes */
+
/* Interface initialialization? */
#define PABLO_MASK H5I_mask
static int interface_initialize_g = 0;
@@ -1107,69 +1117,354 @@ done:
FUNC_LEAVE(ret_value);
}
-
+
+
+
/*-------------------------------------------------------------------------
- * Function: H5I_debug
+ * Function: H5Iget_name
*
- * Purpose: Dump the contents of a group to stderr for debugging.
+ * Purpose: Gets a name of an object from its ID.
*
- * Return: Success: Non-negative
+ * Return: Success: 0, Failure: -1
*
- * Failure: Negative
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
*
- * Programmer: Robb Matzke
- * Friday, February 19, 1999
+ * Date: July 26, 2002
+ *
+ * Comments: Public function
+ * If `name' is non-NULL then write up to `size' bytes into that
+ * buffer and always return the length of the entry name.
+ * Otherwise `size' is ignored and the function does not store the name,
+ * just returning the number of characters required to store the name.
+ * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL)
+ * is unchanged and the function returns a negative value.
+ * If a zero is returned for the name's length, then there is no name
+ * associated with the ID.
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
+
+ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size)
+{
+ H5G_entry_t *ent; /*symbol table entry */
+ size_t len=0;
+ size_t count;
+ ssize_t ret_value;
+
+ FUNC_ENTER_API (H5Iget_name, FAIL);
+
+ /* get symbol table entry */
+ if ( NULL== ( ent = H5G_loc( id )))
+ goto done;
+
+ if ( ent->name != NULL ) {
+
+ len = HDstrlen(ent->name);
+ count = MIN(len+1,size);
+
+ if ( name ) {
+ HDstrncpy( name, ent->name, count );
+ if ( len >= size ) {
+ name[size-1]='\0';
+ }
+ }
+ }
+ else
+ {
+ len = 0;
+ }
+
+done:
+ ret_value = len;
+ FUNC_LEAVE( ret_value );
+}
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5I_debug
+ *
+ * Purpose: Dump the contents of a group to stderr for debugging.
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Robb Matzke
+ * Friday, February 19, 1999
+ *
+ * Modifications:
+ *
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
+ *-------------------------------------------------------------------------
+ */
#ifdef H5I_DEBUG_OUTPUT
static herr_t
H5I_debug(H5I_type_t grp)
{
- H5I_id_group_t *grp_ptr;
- H5I_id_info_t *cur;
- int is, js;
- unsigned int iu;
-
- FUNC_ENTER_NOAPI(H5I_debug, FAIL);
+ H5I_id_group_t *grp_ptr;
+ H5I_id_info_t *cur;
+ int is, js;
+ unsigned int iu;
+ herr_t ret_value; /* Return value */
+
+
+ H5G_entry_t *ent = NULL;
+
+ FUNC_ENTER_API(H5I_debug, FAIL);
+
+ fprintf(stderr, "Dumping group %d\n", (int)grp);
+ grp_ptr = H5I_id_group_list_g[grp];
+
+ /* Header */
+ fprintf(stderr, " count = %u\n", grp_ptr->count);
+ fprintf(stderr, " reserved = %u\n", grp_ptr->reserved);
+ fprintf(stderr, " wrapped = %u\n", grp_ptr->wrapped);
+ fprintf(stderr, " hash_size = %lu\n",
+ (unsigned long)grp_ptr->hash_size);
+ fprintf(stderr, " ids = %u\n", grp_ptr->ids);
+ fprintf(stderr, " nextid = %u\n", grp_ptr->nextid);
+
+ /* Cache */
+ fprintf(stderr, " Cache:\n");
+ for (is=0; is<ID_CACHE_SIZE; is++) {
+ if (H5I_cache_g[is] && H5I_GROUP(H5I_cache_g[is]->id)==grp) {
+ fprintf(stderr, " Entry-%d, ID=%lu\n",
+ is, (unsigned long)(H5I_cache_g[is]->id));
+ }
+ }
+
+ /* List */
+ fprintf(stderr, " List:\n");
+ for (iu=0; iu<grp_ptr->hash_size; iu++) {
+ for (js=0, cur=grp_ptr->id_list[iu]; cur; cur=cur->next, js++) {
+ fprintf(stderr, " #%u.%d\n", iu, js);
+ fprintf(stderr, " id = %lu\n",
+ (unsigned long)(cur->id));
+ fprintf(stderr, " count = %u\n", cur->count);
+ fprintf(stderr, " obj = 0x%08lx\n",
+ (unsigned long)(cur->obj_ptr));
+
+
+ switch(grp) {
- fprintf(stderr, "Dumping group %d\n", (int)grp);
- grp_ptr = H5I_id_group_list_g[grp];
+ case H5I_GROUP:
+ ent = H5G_entof((H5G_t*)cur->obj_ptr);
+ break;
+ case H5I_DATASET:
+ ent = H5D_entof((H5D_t*)cur->obj_ptr);
+ break;
+ case H5I_DATATYPE:
+ ent = H5T_entof((H5T_t*)cur->obj_ptr);
+ break;
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "unknown data object");
+ }/* switch*/
+
+ fprintf(stderr, "name = %s\n",ent->name);
+
+
+
+ }
+ }
+
+done:
+ FUNC_LEAVE(SUCCEED);
+}
+#endif /* H5I_DEBUG_OUTPUT */
- /* Header */
- fprintf(stderr, " count = %u\n", grp_ptr->count);
- fprintf(stderr, " reserved = %u\n", grp_ptr->reserved);
- fprintf(stderr, " wrapped = %u\n", grp_ptr->wrapped);
- fprintf(stderr, " hash_size = %lu\n",
- (unsigned long)grp_ptr->hash_size);
- fprintf(stderr, " ids = %u\n", grp_ptr->ids);
- fprintf(stderr, " nextid = %u\n", grp_ptr->nextid);
-
- /* Cache */
- fprintf(stderr, " Cache:\n");
- for (is=0; is<ID_CACHE_SIZE; is++) {
- if (H5I_cache_g[is] && H5I_GROUP(H5I_cache_g[is]->id)==grp) {
- fprintf(stderr, " Entry-%d, ID=%lu\n",
- is, (unsigned long)(H5I_cache_g[is]->id));
- }
- }
- /* List */
- fprintf(stderr, " List:\n");
- for (iu=0; iu<grp_ptr->hash_size; iu++) {
- for (js=0, cur=grp_ptr->id_list[iu]; cur; cur=cur->next, js++) {
- fprintf(stderr, " #%u.%d\n", iu, js);
- fprintf(stderr, " id = %lu\n",
- (unsigned long)(cur->id));
- fprintf(stderr, " count = %u\n", cur->count);
- fprintf(stderr, " obj = 0x%08lx\n",
- (unsigned long)(cur->obj_ptr));
- }
- }
+/*-------------------------------------------------------------------------
+ * Function: H5I_debug_grp
+ *
+ * Purpose: Dump the contents of a group to stderr for debugging
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: July 26, 2002
+ *
+ * Comments: Public function
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
- FUNC_LEAVE(SUCCEED);
+#ifdef H5I_DEBUG_OUTPUT
+herr_t H5Idebug_grp(H5I_type_t grp)
+{
+ H5I_id_group_t *grp_ptr;
+ H5I_id_info_t *cur;
+ int is, js;
+ unsigned int iu;
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(H5Idebug_grp, FAIL);
+
+ fprintf(stderr, "Dumping group %d\n", (int)grp);
+ grp_ptr = H5I_id_group_list_g[grp];
+
+ /* Header */
+ fprintf(stderr, " count = %u\n", grp_ptr->count);
+ fprintf(stderr, " reserved = %u\n", grp_ptr->reserved);
+ fprintf(stderr, " wrapped = %u\n", grp_ptr->wrapped);
+ fprintf(stderr, " hash_size = %lu\n",
+ (unsigned long)grp_ptr->hash_size);
+ fprintf(stderr, " ids = %u\n", grp_ptr->ids);
+ fprintf(stderr, " nextid = %u\n", grp_ptr->nextid);
+
+ /* Cache */
+ fprintf(stderr, " Cache:\n");
+ for (is=0; is<ID_CACHE_SIZE; is++) {
+ if (H5I_cache_g[is] && H5I_GROUP(H5I_cache_g[is]->id)==grp) {
+ fprintf(stderr, " Entry-%d, ID=%lu\n",
+ is, (unsigned long)(H5I_cache_g[is]->id));
+ }
+ }
+
+ /* List */
+ fprintf(stderr, " List:\n");
+ for (iu=0; iu<grp_ptr->hash_size; iu++) {
+ for (js=0, cur=grp_ptr->id_list[iu]; cur; cur=cur->next, js++) {
+
+ /* avoid no named datatypes */
+ if( grp==H5I_DATATYPE && H5T_is_immutable((H5T_t*)cur->obj_ptr))
+ break;
+
+
+ fprintf(stderr, " #%u.%d\n", iu, js);
+ fprintf(stderr, " id = %lu\n",
+ (unsigned long)(cur->id));
+ fprintf(stderr, " count = %u\n", cur->count);
+ fprintf(stderr, " obj = 0x%08lx\n",
+ (unsigned long)(cur->obj_ptr));
+ }
+ }
+
+done:
+ FUNC_LEAVE(SUCCEED);
}
#endif /* H5I_DEBUG_OUTPUT */
+
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Idebug_name
+ *
+ * Purpose: Dump the contents of a group to stderr for debugging
+ *
+ * Return: Success: 0, Failure: -1
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: July 26, 2002
+ *
+ * Comments: Public function
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#ifdef H5I_DEBUG_OUTPUT
+herr_t H5Idebug_name(hid_t id)
+{
+
+ H5I_type_t grp_type; /* group type */
+ H5I_id_group_t *grp_ptr; /* ptr to the atomic group */
+ H5I_id_info_t *cur=NULL; /* Current node being worked with */
+ H5I_id_info_t *next=NULL; /* Next node in list */
+ unsigned i;
+
+ H5G_entry_t *ent = NULL;
+ H5G_t *group=NULL;
+ H5T_t *dt=NULL;
+ H5D_t *dset=NULL;
+ herr_t ret_value; /* Return value */
+
+ FUNC_ENTER_API (H5Idebug_name, FAIL);
+
+ grp_type = H5I_get_type(id);
+
+ /* Check it */
+ if (grp_type <= H5I_BADID || grp_type >= H5I_NGROUPS) {
+ HRETURN(FAIL);
+ }
+
+ grp_ptr = H5I_id_group_list_g[grp_type];
+ if (grp_ptr == NULL || grp_ptr->count <= 0) {
+ HRETURN(FAIL);
+ }
+
+ /* Cache */
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Cache:\n");
+ for (i=0; i<ID_CACHE_SIZE; i++) {
+ if (H5I_cache_g[i] && H5I_GROUP(H5I_cache_g[i]->id)==grp_type) {
+
+ cur = H5I_cache_g[i];
+ fprintf(stderr, " Entry-%d, ID=%lu\n", i, cur->id);
+
+ switch(grp_type) {
+ case H5I_GROUP:
+ ent = H5G_entof((H5G_t*)cur->obj_ptr);
+ break;
+ case H5I_DATASET:
+ ent = H5D_entof((H5D_t*)cur->obj_ptr);
+ break;
+ case H5I_DATATYPE:
+ ent = H5T_entof((H5T_t*)cur->obj_ptr);
+ break;
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "unknown data object");
+ }/* switch*/
+
+ fprintf(stderr, "name = %s\n",ent->name);
+
+ }
+ }
+
+ /* List */
+ fprintf(stderr, "List:\n");
+ for (i=0; i<grp_ptr->hash_size; i++) {
+ for (cur=grp_ptr->id_list[i]; cur; cur=next) {
+
+ switch(grp_type) {
+
+ case H5I_GROUP:
+ ent = H5G_entof((H5G_t*)cur->obj_ptr);
+ break;
+ case H5I_DATASET:
+ ent = H5D_entof((H5D_t*)cur->obj_ptr);
+ break;
+ case H5I_DATATYPE:
+ ent = H5T_entof((H5T_t*)cur->obj_ptr);
+ break;
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "unknown data object");
+ }/* switch*/
+
+ /* can be NULL in case of named datatypes */
+ if (ent)
+ {
+ fprintf(stderr, "id = %lu\n",(unsigned long)(cur->id));
+ fprintf(stderr, "name = %s\n",ent->name);
+ }
+
+ }
+ }
+
+done:
+ FUNC_LEAVE(SUCCEED);
+}
+#endif /* H5I_DEBUG_OUTPUT */ \ No newline at end of file
diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h
index 85db6fd..2773f66 100644
--- a/src/H5Ipublic.h
+++ b/src/H5Ipublic.h
@@ -52,6 +52,10 @@ extern "C" {
#endif
__DLL__ H5I_type_t H5Iget_type(hid_t id);
+__DLL__ ssize_t H5Iget_name(hid_t object_id, char *name/*out*/, size_t size);
+__DLL__ herr_t H5Idebug_name(hid_t id);
+__DLL__ herr_t H5Idebug_grp(H5I_type_t grp);
+
#ifdef __cplusplus
diff --git a/src/H5O.c b/src/H5O.c
index 900cd8c..0ce00e4 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -269,6 +269,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
herr_t
@@ -306,6 +309,13 @@ H5O_close(H5G_entry_t *obj_ent)
if (0==obj_ent->file->nopen_objs && obj_ent->file->closing)
H5I_dec_ref(obj_ent->file->closing);
+
+ /* Free the ID to name buffers */
+ if ( obj_ent->name )
+ obj_ent->name = H5MM_xfree(obj_ent->name);
+ if ( obj_ent->old_name )
+ obj_ent->old_name = H5MM_xfree(obj_ent->old_name);
+
done:
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 772cac7..81ea37b 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -1108,6 +1108,9 @@ done:
*
* Modifications:
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added `id to name' support.
+ *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -1123,8 +1126,13 @@ H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/,
assert (sh);
assert (!sh->in_gh);
- dt->ent = sh->u.ent;
- dt->state = H5T_STATE_NAMED;
+ dt->ent = sh->u.ent;
+
+ dt->ent.name = NULL;
+ dt->ent.old_name = NULL;
+
+ dt->state = H5T_STATE_NAMED;
+
done:
FUNC_LEAVE (ret_value);
diff --git a/src/H5T.c b/src/H5T.c
index bc54b58..08f10f0 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -5406,6 +5406,9 @@ done:
* Robb Matzke, 20 May 1999
* Now able to copy opaque types.
*
+ * Pedro Vicente, <pvn@ncsa.uiuc.edu> 22 Aug 2002
+ * Added a deep copy of the symbol table entry
+ *
*-------------------------------------------------------------------------
*/
H5T_t *
@@ -5425,9 +5428,14 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
if (NULL==(new_dt = H5FL_ALLOC(H5T_t,0)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- /* Copy actual information */
+ /* Copy actual information */
*new_dt = *old_dt;
+ /* Deep copy of the symbol table entry */
+ if (H5G_ent_copy(&(old_dt->ent),&(new_dt->ent))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to copy entry");
+
+
/* Copy parent information */
if (new_dt->parent)
new_dt->parent = H5T_copy(new_dt->parent, method);