summaryrefslogtreecommitdiffstats
path: root/src/H5I.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-11-15 02:55:39 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-11-15 02:55:39 (GMT)
commita1708eb023f2c8f8ac6c2c17bf1e598c8dff956e (patch)
tree34c87a3753b36c4c8d689d58bf456eaf261cd235 /src/H5I.c
parentbea1e576c5ef5500678f7ce913d835341b625e8f (diff)
downloadhdf5-a1708eb023f2c8f8ac6c2c17bf1e598c8dff956e.zip
hdf5-a1708eb023f2c8f8ac6c2c17bf1e598c8dff956e.tar.gz
hdf5-a1708eb023f2c8f8ac6c2c17bf1e598c8dff956e.tar.bz2
[svn-r11712] Purpose:
New feature Description: Check in baseline for compact group revisions, which radically revises the source code for managing groups and object headers. WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! This initiates the "unstable" phase of the 1.7.x branch, leading up to the 1.8.0 release. Please test this code, but do _NOT_ keep files created with it - the format will change again before the release and you will not be able to read your old files!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! WARNING!!!! Solution: There's too many changes to really describe them all, but some of them include: - Stop abusing the H5G_entry_t structure and split it into two separate structures for non-symbol table node use within the library: H5O_loc_t for object locations in a file and H5G_name_t to store the path to an opened object. H5G_entry_t is now only used for storing symbol table entries on disk. - Retire H5G_namei() in favor of a more general mechanism for traversing group paths and issuing callbacks on objects located. This gets us out of the business of hacking H5G_namei() for new features, generally. - Revised H5O* routines to take a H5O_loc_t instead of H5G_entry_t - Lots more... Platforms tested: h5committested and maybe another dozen configurations.... :-)
Diffstat (limited to 'src/H5I.c')
-rw-r--r--src/H5I.c211
1 files changed, 105 insertions, 106 deletions
diff --git a/src/H5I.c b/src/H5I.c
index a0e2096..bfcef6b 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -45,6 +45,7 @@
#include "H5FLprivate.h" /* Free Lists */
#include "H5Ipkg.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
+#include "H5Oprivate.h" /* Object headers */
/* Define this to compile in support for dumping ID information */
/* #define H5I_DEBUG_OUTPUT */
@@ -2003,28 +2004,61 @@ H5I_find_id(hid_t id)
ssize_t
H5Iget_name(hid_t id, char *name/*out*/, size_t size)
{
- H5G_entry_t *ent; /*symbol table entry */
- size_t len=0;
+ H5G_loc_t loc; /* Object location */
+ size_t len = 0;
ssize_t ret_value;
- FUNC_ENTER_API (H5Iget_name, FAIL);
+ FUNC_ENTER_API(H5Iget_name, FAIL)
H5TRACE3("Zs","ixz",id,name,size);
- /* get symbol table entry */
- if(NULL!=(ent = H5G_loc(id))) {
- if (ent->user_path_r != NULL && ent->user_path_hidden==0) {
- len = H5RS_len(ent->user_path_r);
+ /* get object location */
+ if(H5G_loc(id, &loc) >= 0) {
+ if(loc.path->user_path_r != NULL && loc.path->user_path_hidden == 0) {
+ len = H5RS_len(loc.path->user_path_r);
if(name) {
- HDstrncpy(name, H5RS_get_str(ent->user_path_r), MIN(len+1,size));
+ HDstrncpy(name, H5RS_get_str(loc.path->user_path_r), MIN(len + 1, size));
if(len >= size)
- name[size-1]='\0';
+ name[size-1] = '\0';
} /* end if */
} /* end if */
} /* end if */
/* Set return value */
- ret_value=(ssize_t)len;
+ ret_value = (ssize_t)len;
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Iget_name() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Iget_file_id
+ *
+ * Purpose: The public version of H5I_get_file_id(), obtains the file
+ * ID given an object ID. User has to close this ID.
+ *
+ * Return: Success: file ID
+ *
+ * Failure: a negative value
+ *
+ * Programmer: Raymond Lu
+ * Oct 27, 2003
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Iget_file_id(hid_t obj_id)
+{
+ hid_t ret_value;
+
+ FUNC_ENTER_API(H5Iget_file_id, FAIL);
+ H5TRACE1("i","i",obj_id);
+
+ if((ret_value = H5I_get_file_id(obj_id))<0)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID");
done:
FUNC_LEAVE_API(ret_value);
@@ -2032,6 +2066,57 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5I_get_file_id
+ *
+ * Purpose: The private version of H5Iget_file_id(), obtains the file
+ * ID given an object ID.
+ *
+ * Return: Success: file ID
+ *
+ * Failure: a negative value
+ *
+ * Programmer: Raymond Lu
+ * Oct 27, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+H5I_get_file_id(hid_t obj_id)
+{
+ H5G_loc_t loc; /* Location of object */
+ H5I_type_t type; /* ID type */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5I_get_file_id)
+
+ /* Get object type */
+ type = H5I_TYPE(obj_id);
+ if(type == H5I_FILE) {
+ ret_value = obj_id;
+
+ /* Increment reference count on atom. */
+ if(H5I_inc_ref(ret_value) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
+ }
+ else if(type == H5I_DATATYPE) {
+ if(H5G_loc(obj_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "not a named datatype")
+ ret_value = H5F_get_id(loc.oloc->file);
+ }
+ else if(type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) {
+ if(H5G_loc(obj_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get symbol table info")
+ ret_value = H5F_get_id(loc.oloc->file);
+ }
+ else
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5I_get_file_id() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5I_debug
*
* Purpose: Dump the contents of a type to stderr for debugging.
@@ -2056,7 +2141,7 @@ H5I_debug(H5I_type_t type)
{
H5I_id_type_t *type_ptr;
H5I_id_info_t *cur;
- H5G_entry_t *ent = NULL;
+ H5G_name_t *path;
int is, js;
unsigned int iu;
herr_t ret_value; /* Return value */
@@ -2092,26 +2177,26 @@ H5I_debug(H5I_type_t type)
fprintf(stderr, " count = %u\n", cur->count);
fprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(cur->obj_ptr));
- /* Get the symbol table entry, so we get get the name */
+ /* Get the group location, so we get get the name */
switch(type) {
case H5I_GROUP:
- ent = H5G_entof((H5G_t*)cur->obj_ptr);
+ path = H5G_nameof((H5G_t*)cur->obj_ptr);
break;
case H5I_DATASET:
- ent = H5D_entof((H5D_t*)cur->obj_ptr);
+ path = H5D_nameof((H5D_t*)cur->obj_ptr);
break;
case H5I_DATATYPE:
- ent = H5T_entof((H5T_t*)cur->obj_ptr);
+ path = H5T_nameof((H5T_t*)cur->obj_ptr);
break;
default:
continue; /* Other types of IDs are not stored in files */
} /* end switch*/
- if(ent) {
- if(ent->name)
- fprintf(stderr, " name = %s\n",ent->name);
- if(ent->old_name)
- fprintf(stderr, " old_name = %s\n",ent->old_name);
+ if(path) {
+ if(path->user_path_r)
+ fprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r));
+ if(ent->canon_path_r)
+ fprintf(stderr, " canon_path = %s\n", H5RS_get_str(path->canon_path_r));
} /* end if */
} /* end for */
} /* end for */
@@ -2121,89 +2206,3 @@ done:
}
#endif /* H5I_DEBUG_OUTPUT */
-
-/*-------------------------------------------------------------------------
- * Function: H5Iget_file_id
- *
- * Purpose: The public version of H5I_get_file_id(), obtains the file
- * ID given an object ID. User has to close this ID.
- *
- * Return: Success: file ID
- *
- * Failure: a negative value
- *
- * Programmer: Raymond Lu
- * Oct 27, 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5Iget_file_id(hid_t obj_id)
-{
- hid_t ret_value;
-
- FUNC_ENTER_API(H5Iget_file_id, FAIL);
- H5TRACE1("i","i",obj_id);
-
- if((ret_value = H5I_get_file_id(obj_id))<0)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID");
-
-done:
- FUNC_LEAVE_API(ret_value);
-}
-
-
-/*-------------------------------------------------------------------------
- * Function: H5I_get_file_id
- *
- * Purpose: The private version of H5Iget_file_id(), obtains the file
- * ID given an object ID.
- *
- * Return: Success: file ID
- *
- * Failure: a negative value
- *
- * Programmer: Raymond Lu
- * Oct 27, 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static hid_t
-H5I_get_file_id(hid_t obj_id)
-{
- H5G_entry_t *ent;
- H5I_type_t type;
- hid_t ret_value;
-
- FUNC_ENTER_NOAPI_NOINIT(H5I_get_file_id);
-
- /* Get object type */
- type = H5I_TYPE(obj_id);
- if(type == H5I_FILE) {
- ret_value = obj_id;
-
- /* Increment reference count on atom. */
- if (H5I_inc_ref(ret_value)<0)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed");
- }
- else if(type == H5I_DATATYPE) {
- if((ent = H5G_loc(obj_id))==NULL)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "not a named datatype");
- ret_value = H5F_get_id(ent->file);
- }
- else if(type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) {
- if((ent = H5G_loc(obj_id))==NULL)
- HGOTO_ERROR (H5E_ATOM, H5E_CANTGET, FAIL, "can't get symbol table info");
- ret_value = H5F_get_id(ent->file);
- }
- else
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID");
-
-done:
- FUNC_LEAVE_NOAPI(ret_value);
-}
-